mp_aframe_create:
   53|   292k|{
   54|   292k|    struct mp_aframe *frame = talloc_zero(NULL, struct mp_aframe);
  ------------------
  |  |   27|   292k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   292k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   292k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|   292k|    frame->av_frame = av_frame_alloc();
   56|   292k|    MP_HANDLE_OOM(frame->av_frame);
  ------------------
  |  |  206|   292k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|   292k|        void *oom_p_ = (x);     \
  |  |  208|   292k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 292k]
  |  |  ------------------
  |  |  209|   292k|            abort();            \
  |  |  210|   292k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 292k]
  |  |  ------------------
  ------------------
   57|   292k|    talloc_set_destructor(frame, free_frame);
  ------------------
  |  |   41|   292k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   58|   292k|    mp_aframe_reset(frame);
   59|   292k|    return frame;
   60|   292k|}
mp_aframe_reset:
   87|   292k|{
   88|   292k|    av_frame_unref(frame->av_frame);
   89|   292k|    frame->chmap.num = 0;
   90|   292k|    frame->format = 0;
   91|   292k|    frame->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   292k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   92|   292k|    frame->speed = 1.0;
   93|   292k|}
aframe.c:free_frame:
   47|   292k|{
   48|   292k|    struct mp_aframe *frame = ptr;
   49|   292k|    av_frame_free(&frame->av_frame);
   50|   292k|}

mp_chmap_is_valid:
  126|    506|{
  127|    506|    bool mapped[MP_SPEAKER_ID_COUNT] = {0};
  128|    506|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (128:21): [True: 0, False: 506]
  ------------------
  129|      0|        int sp = src->speaker[n];
  130|      0|        if (sp >= MP_SPEAKER_ID_COUNT || mapped[sp])
  ------------------
  |  Branch (130:13): [True: 0, False: 0]
  |  Branch (130:42): [True: 0, False: 0]
  ------------------
  131|      0|            return false;
  132|      0|        if (sp != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (132:13): [True: 0, False: 0]
  ------------------
  133|      0|            mapped[sp] = true;
  134|      0|    }
  135|    506|    return src->num > 0;
  136|    506|}
mp_chmap_is_unknown:
  146|    253|{
  147|    253|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (147:21): [True: 0, False: 253]
  ------------------
  148|      0|        if (src->speaker[n] != MP_SPEAKER_ID_NA)
  ------------------
  |  Branch (148:13): [True: 0, False: 0]
  ------------------
  149|      0|            return false;
  150|      0|    }
  151|    253|    return mp_chmap_is_valid(src);
  152|    253|}
mp_chmap_from_channels:
  218|  24.1k|{
  219|  24.1k|    *dst = (struct mp_chmap) {0};
  220|  24.1k|    if (num_channels >= 0 && num_channels < MP_ARRAY_SIZE(default_layouts))
  ------------------
  |  |   49|  24.1k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (220:9): [True: 24.1k, False: 0]
  |  Branch (220:30): [True: 23.3k, False: 845]
  ------------------
  221|  23.3k|        *dst = default_layouts[num_channels];
  222|  24.1k|    if (!dst->num)
  ------------------
  |  Branch (222:9): [True: 23.3k, False: 820]
  ------------------
  223|  23.3k|        mp_chmap_set_unknown(dst, num_channels);
  224|  24.1k|}
mp_chmap_set_unknown:
  232|  23.6k|{
  233|  23.6k|    if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) {
  ------------------
  |  |   25|  23.6k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (233:9): [True: 0, False: 23.6k]
  |  Branch (233:29): [True: 71, False: 23.5k]
  ------------------
  234|     71|        *dst = (struct mp_chmap) {0};
  235|  23.5k|    } else {
  236|  23.5k|        dst->num = num_channels;
  237|  43.8k|        for (int n = 0; n < dst->num; n++)
  ------------------
  |  Branch (237:25): [True: 20.2k, False: 23.5k]
  ------------------
  238|  20.2k|            dst->speaker[n] = MP_SPEAKER_ID_NA;
  239|  23.5k|    }
  240|  23.6k|}
mp_chmap_to_lavc:
  269|    253|{
  270|    253|    if (!mp_chmap_is_lavc(src))
  ------------------
  |  Branch (270:9): [True: 253, False: 0]
  ------------------
  271|    253|        return 0;
  272|      0|    return mp_chmap_to_lavc_unchecked(src);
  273|    253|}
mp_chmap_from_lavc:
  279|  3.92k|{
  280|  3.92k|    dst->num = 0;
  281|   255k|    for (int n = 0; n < 64; n++) {
  ------------------
  |  Branch (281:21): [True: 251k, False: 3.92k]
  ------------------
  282|   251k|        if (src & (1ULL << n)) {
  ------------------
  |  Branch (282:13): [True: 10.8k, False: 240k]
  ------------------
  283|  10.8k|            if (dst->num >= MP_NUM_CHANNELS) {
  ------------------
  |  |   25|  10.8k|#define MP_NUM_CHANNELS 64
  ------------------
  |  Branch (283:17): [True: 0, False: 10.8k]
  ------------------
  284|      0|                dst->num = 0;
  285|      0|                return;
  286|      0|            }
  287|  10.8k|            dst->speaker[dst->num] = n;
  288|  10.8k|            dst->num++;
  289|  10.8k|        }
  290|   251k|    }
  291|  3.92k|}
mp_chmap_is_lavc:
  294|    253|{
  295|    253|    if (!mp_chmap_is_valid(src))
  ------------------
  |  Branch (295:9): [True: 253, False: 0]
  ------------------
  296|    253|        return false;
  297|      0|    if (mp_chmap_is_unknown(src))
  ------------------
  |  Branch (297:9): [True: 0, False: 0]
  ------------------
  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|      0|    mp_assert(src->num > 0);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 0, False: 0]
  ------------------
  302|      0|    for (int n = 1; n < src->num; n++) {
  ------------------
  |  Branch (302:21): [True: 0, False: 0]
  ------------------
  303|      0|        if (src->speaker[n - 1] >= src->speaker[n])
  ------------------
  |  Branch (303:13): [True: 0, False: 0]
  ------------------
  304|      0|            return false;
  305|      0|    }
  306|      0|    for (int n = 0; n < src->num; n++) {
  ------------------
  |  Branch (306:21): [True: 0, False: 0]
  ------------------
  307|      0|        if (src->speaker[n] >= 64)
  ------------------
  |  Branch (307:13): [True: 0, False: 0]
  ------------------
  308|      0|            return false;
  309|      0|    }
  310|      0|    return true;
  311|      0|}

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

ao_hotplug_destroy:
  587|  32.5k|{
  588|  32.5k|    if (!hp)
  ------------------
  |  Branch (588:9): [True: 32.5k, False: 0]
  ------------------
  589|  32.5k|        return;
  590|      0|    if (hp->ao && hp->ao->driver->hotplug_uninit)
  ------------------
  |  Branch (590:9): [True: 0, False: 0]
  |  Branch (590:19): [True: 0, False: 0]
  ------------------
  591|      0|        hp->ao->driver->hotplug_uninit(hp->ao);
  592|      0|    talloc_free(hp->ao);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  593|      0|    talloc_free(hp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  594|      0|}
ao.c:get_desc:
  116|   260k|{
  117|   260k|    if (index >= MP_ARRAY_SIZE(audio_out_drivers))
  ------------------
  |  |   49|   260k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (117:9): [True: 32.5k, False: 227k]
  ------------------
  118|  32.5k|        return false;
  119|   227k|    const struct ao_driver *ao = audio_out_drivers[index];
  120|   227k|    *dst = (struct m_obj_desc) {
  121|   227k|        .name = ao->name,
  122|   227k|        .description = ao->description,
  123|   227k|        .priv_size = ao->priv_size,
  124|   227k|        .priv_defaults = ao->priv_defaults,
  125|   227k|        .options = ao->options,
  126|   227k|        .options_prefix = ao->options_prefix,
  127|   227k|        .global_opts = ao->global_opts,
  128|   227k|        .hidden = ao->encode,
  129|   227k|        .p = ao,
  130|   227k|    };
  131|       |    return true;
  132|   260k|}

mp_to_av_stream_type:
   44|    253|{
   45|    253|    switch (type) {
   46|    253|    case STREAM_VIDEO: return AVMEDIA_TYPE_VIDEO;
  ------------------
  |  Branch (46:5): [True: 253, False: 0]
  ------------------
   47|      0|    case STREAM_AUDIO: return AVMEDIA_TYPE_AUDIO;
  ------------------
  |  Branch (47:5): [True: 0, False: 253]
  ------------------
   48|      0|    case STREAM_SUB:   return AVMEDIA_TYPE_SUBTITLE;
  ------------------
  |  Branch (48:5): [True: 0, False: 253]
  ------------------
   49|      0|    default:           return AVMEDIA_TYPE_UNKNOWN;
  ------------------
  |  Branch (49:5): [True: 0, False: 253]
  ------------------
   50|    253|    }
   51|    253|}
mp_codec_params_to_av:
   54|  38.8k|{
   55|  38.8k|    AVCodecParameters *avp = avcodec_parameters_alloc();
   56|  38.8k|    if (!avp)
  ------------------
  |  Branch (56:9): [True: 0, False: 38.8k]
  ------------------
   57|      0|        return NULL;
   58|       |
   59|       |    // If we have lavf demuxer params, they overwrite by definition any others.
   60|  38.8k|    if (c->lav_codecpar) {
  ------------------
  |  Branch (60:9): [True: 38.6k, False: 253]
  ------------------
   61|  38.6k|        if (avcodec_parameters_copy(avp, c->lav_codecpar) < 0)
  ------------------
  |  Branch (61:13): [True: 0, False: 38.6k]
  ------------------
   62|      0|            goto error;
   63|  38.6k|        return avp;
   64|  38.6k|    }
   65|       |
   66|    253|    avp->codec_type = mp_to_av_stream_type(c->type);
   67|    253|    avp->codec_id = mp_codec_to_av_codec_id(c->codec);
   68|    253|    avp->codec_tag = c->codec_tag;
   69|    253|    if (c->extradata_size) {
  ------------------
  |  Branch (69:9): [True: 228, False: 25]
  ------------------
   70|    228|        uint8_t *extradata = c->extradata;
   71|    228|        int size = c->extradata_size;
   72|       |
   73|    228|        if (avp->codec_id == AV_CODEC_ID_FLAC) {
  ------------------
  |  Branch (73:13): [True: 0, False: 228]
  ------------------
   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|    228|        avp->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
   83|    228|        if (!avp->extradata)
  ------------------
  |  Branch (83:13): [True: 0, False: 228]
  ------------------
   84|      0|            goto error;
   85|    228|        avp->extradata_size = size;
   86|    228|        memcpy(avp->extradata, extradata, size);
   87|    228|    }
   88|    253|    avp->bits_per_coded_sample = c->bits_per_coded_sample;
   89|       |
   90|       |    // Video only
   91|    253|    avp->width = c->disp_w;
   92|    253|    avp->height = c->disp_h;
   93|       |
   94|       |    // Audio only
   95|    253|    avp->sample_rate = c->samplerate;
   96|    253|    avp->bit_rate = c->bitrate;
   97|    253|    avp->block_align = c->block_align;
   98|       |
   99|    253|    mp_chmap_to_av_layout(&avp->ch_layout, &c->channels);
  100|       |
  101|    253|    return avp;
  102|      0|error:
  103|      0|    avcodec_parameters_free(&avp);
  104|       |    return NULL;
  105|    253|}
mp_set_avctx_codec_headers:
  109|  38.6k|{
  110|  38.6k|    enum AVMediaType codec_type = avctx->codec_type;
  111|  38.6k|    enum AVCodecID codec_id = avctx->codec_id;
  112|  38.6k|    AVCodecParameters *avp = mp_codec_params_to_av(c);
  113|  38.6k|    if (!avp)
  ------------------
  |  Branch (113:9): [True: 0, False: 38.6k]
  ------------------
  114|      0|        return -1;
  115|       |
  116|  38.6k|    int r = avcodec_parameters_to_context(avctx, avp) < 0 ? -1 : 0;
  ------------------
  |  Branch (116:13): [True: 0, False: 38.6k]
  ------------------
  117|  38.6k|    avcodec_parameters_free(&avp);
  118|       |
  119|  38.6k|    if (avctx->codec_type != AVMEDIA_TYPE_UNKNOWN)
  ------------------
  |  Branch (119:9): [True: 38.6k, False: 0]
  ------------------
  120|  38.6k|        avctx->codec_type = codec_type;
  121|  38.6k|    if (avctx->codec_id != AV_CODEC_ID_NONE)
  ------------------
  |  Branch (121:9): [True: 38.6k, False: 0]
  ------------------
  122|  38.6k|        avctx->codec_id = codec_id;
  123|  38.6k|    return r;
  124|  38.6k|}
mp_get_codec_timebase:
  129|  32.7k|{
  130|  32.7k|    AVRational tb = {c->native_tb_num, c->native_tb_den};
  131|  32.7k|    if (tb.num < 1 || tb.den < 1) {
  ------------------
  |  Branch (131:9): [True: 0, False: 32.7k]
  |  Branch (131:23): [True: 0, False: 32.7k]
  ------------------
  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|  32.7k|    int64_t den = tb.den;
  141|  32.7k|    if (av_q2d(tb) > 0.001) {
  ------------------
  |  Branch (141:9): [True: 32.5k, False: 207]
  ------------------
  142|  32.5k|        int64_t scaling_num = tb.num * INT64_C(1000);
  143|  32.5k|        int64_t scaling_den = tb.den;
  144|  32.5k|        den *= (scaling_num + scaling_den - 1) / scaling_den;
  145|  32.5k|    }
  146|       |
  147|  32.7k|    av_reduce(&tb.num, &tb.den, tb.num, den, INT_MAX);
  148|       |
  149|  32.7k|    if (tb.num < 1 || tb.den < 1)
  ------------------
  |  Branch (149:9): [True: 0, False: 32.7k]
  |  Branch (149:23): [True: 0, False: 32.7k]
  ------------------
  150|      0|        tb = AV_TIME_BASE_Q;
  151|       |
  152|  32.7k|    return tb;
  153|  32.7k|}
mp_pts_to_av:
  163|  1.81M|{
  164|  1.81M|    AVRational b = get_def_tb(tb);
  165|  1.81M|    return mp_pts == MP_NOPTS_VALUE ? AV_NOPTS_VALUE : llrint(mp_pts / av_q2d(b));
  ------------------
  |  |   39|  1.81M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (165:12): [True: 65.0k, False: 1.75M]
  ------------------
  166|  1.81M|}
mp_pts_from_av:
  170|  4.31M|{
  171|  4.31M|    AVRational b = get_def_tb(tb);
  172|  4.31M|    return av_pts == AV_NOPTS_VALUE ? MP_NOPTS_VALUE : av_pts * av_q2d(b);
  ------------------
  |  |   39|      2|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (172:12): [True: 2, False: 4.31M]
  ------------------
  173|  4.31M|}
mp_set_av_packet:
  180|   908k|{
  181|   908k|    dst->side_data = NULL;
  182|   908k|    dst->side_data_elems = 0;
  183|   908k|    dst->buf = NULL;
  184|   908k|    av_packet_unref(dst);
  185|       |
  186|   908k|    dst->data = mpkt ? mpkt->buffer : NULL;
  ------------------
  |  Branch (186:17): [True: 875k, False: 32.5k]
  ------------------
  187|   908k|    dst->size = mpkt ? mpkt->len : 0;
  ------------------
  |  Branch (187:17): [True: 875k, False: 32.5k]
  ------------------
  188|       |    /* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info
  189|       |     * from demuxer. */
  190|   908k|    if (mpkt && mpkt->keyframe)
  ------------------
  |  Branch (190:9): [True: 875k, False: 32.5k]
  |  Branch (190:17): [True: 875k, False: 0]
  ------------------
  191|   875k|        dst->flags |= AV_PKT_FLAG_KEY;
  192|   908k|    if (mpkt && mpkt->avpacket) {
  ------------------
  |  Branch (192:9): [True: 875k, False: 32.5k]
  |  Branch (192:17): [True: 875k, False: 0]
  ------------------
  193|   875k|        dst->side_data = mpkt->avpacket->side_data;
  194|   875k|        dst->side_data_elems = mpkt->avpacket->side_data_elems;
  195|   875k|        if (dst->data == mpkt->avpacket->data)
  ------------------
  |  Branch (195:13): [True: 875k, False: 0]
  ------------------
  196|   875k|            dst->buf = mpkt->avpacket->buf;
  197|   875k|        dst->flags |= mpkt->avpacket->flags;
  198|   875k|    }
  199|   908k|    if (mpkt && tb && tb->num > 0 && tb->den > 0)
  ------------------
  |  Branch (199:9): [True: 875k, False: 32.5k]
  |  Branch (199:17): [True: 875k, False: 0]
  |  Branch (199:23): [True: 875k, False: 0]
  |  Branch (199:38): [True: 875k, False: 0]
  ------------------
  200|   875k|        dst->duration = mpkt->duration / av_q2d(*tb);
  201|   908k|    dst->pts = mp_pts_to_av(mpkt ? mpkt->pts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  32.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (201:29): [True: 875k, False: 32.5k]
  ------------------
  202|   908k|    dst->dts = mp_pts_to_av(mpkt ? mpkt->dts : MP_NOPTS_VALUE, tb);
  ------------------
  |  |   39|  32.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (202:29): [True: 875k, False: 32.5k]
  ------------------
  203|   908k|}
mp_set_avcodec_threads:
  206|  32.5k|{
  207|  32.5k|    if (threads == 0) {
  ------------------
  |  Branch (207:9): [True: 32.5k, False: 0]
  ------------------
  208|  32.5k|        threads = av_cpu_count();
  209|  32.5k|        if (threads < 1) {
  ------------------
  |  Branch (209:13): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|        } else {
  213|  32.5k|            mp_verbose(l, "Detected %d logical cores.\n", threads);
  ------------------
  |  |   79|  32.5k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  214|  32.5k|            if (threads > 1)
  ------------------
  |  Branch (214:17): [True: 32.5k, False: 0]
  ------------------
  215|  32.5k|                threads += 1; // extra thread for better load balancing
  216|  32.5k|        }
  217|       |        // Apparently some libavcodec versions have or had trouble with more
  218|       |        // than 16 threads, and/or print a warning when using > 16.
  219|  32.5k|        threads = MPMIN(threads, 16);
  ------------------
  |  |   45|  32.5k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 32.5k, False: 0]
  |  |  ------------------
  ------------------
  220|  32.5k|    }
  221|  32.5k|    mp_verbose(l, "Requesting %d threads for decoding.\n", threads);
  ------------------
  |  |   79|  32.5k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
  222|  32.5k|    avctx->thread_count = threads;
  223|  32.5k|}
mp_add_lavc_decoders:
  243|  32.5k|{
  244|       |    add_codecs(list, type, true);
  245|  32.5k|}
mp_codec_to_av_codec_id:
  281|  41.4k|{
  282|  41.4k|    int id = AV_CODEC_ID_NONE;
  283|  41.4k|    if (codec) {
  ------------------
  |  Branch (283:9): [True: 41.3k, False: 114]
  ------------------
  284|  41.3k|        const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name(codec);
  285|  41.3k|        if (desc)
  ------------------
  |  Branch (285:13): [True: 19.5k, False: 21.7k]
  ------------------
  286|  19.5k|            id = desc->id;
  287|  41.3k|        if (id == AV_CODEC_ID_NONE) {
  ------------------
  |  Branch (287:13): [True: 21.7k, False: 19.5k]
  ------------------
  288|  21.7k|            const AVCodec *avcodec = avcodec_find_decoder_by_name(codec);
  289|  21.7k|            if (avcodec)
  ------------------
  |  Branch (289:17): [True: 0, False: 21.7k]
  ------------------
  290|      0|                id = avcodec->id;
  291|  21.7k|        }
  292|  41.3k|    }
  293|  41.4k|    return id;
  294|  41.4k|}
mp_codec_from_av_codec_id:
  297|  8.40M|{
  298|  8.40M|    const char *name = NULL;
  299|  8.40M|    const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
  300|  8.40M|    if (desc)
  ------------------
  |  Branch (300:9): [True: 8.38M, False: 22.8k]
  ------------------
  301|  8.38M|        name = desc->name;
  302|  8.40M|    if (!name) {
  ------------------
  |  Branch (302:9): [True: 22.8k, False: 8.38M]
  ------------------
  303|  22.8k|        const AVCodec *avcodec = avcodec_find_decoder(codec_id);
  304|  22.8k|        if (avcodec)
  ------------------
  |  Branch (304:13): [True: 0, False: 22.8k]
  ------------------
  305|      0|            name = avcodec->name;
  306|  22.8k|    }
  307|  8.40M|    return name;
  308|  8.40M|}
mp_codec_is_lossless:
  311|  28.3k|{
  312|  28.3k|    const AVCodecDescriptor *desc =
  313|  28.3k|        avcodec_descriptor_get(mp_codec_to_av_codec_id(codec));
  314|  28.3k|    return desc && (desc->props & AV_CODEC_PROP_LOSSLESS);
  ------------------
  |  Branch (314:12): [True: 6.65k, False: 21.7k]
  |  Branch (314:20): [True: 771, False: 5.88k]
  ------------------
  315|  28.3k|}
mp_set_avdict:
  320|  92.5k|{
  321|  92.5k|    for (int n = 0; kv && kv[n * 2]; n++)
  ------------------
  |  Branch (321:21): [True: 0, False: 92.5k]
  |  Branch (321:27): [True: 0, False: 0]
  ------------------
  322|      0|        av_dict_set(dict, kv[n * 2 + 0], kv[n * 2 + 1], 0);
  323|  92.5k|}
mp_avdict_print_unset:
  328|  58.3k|{
  329|  58.3k|    AVDictionaryEntry *t = NULL;
  330|   188k|    while ((t = av_dict_get(dict, "", t, AV_DICT_IGNORE_SUFFIX)))
  ------------------
  |  Branch (330:12): [True: 130k, False: 58.3k]
  ------------------
  331|   130k|        mp_msg(log, msgl, "Could not set AVOption %s='%s'\n", t->key, t->value);
  332|  58.3k|}
mp_set_avopts:
  369|  32.7k|{
  370|  32.7k|    return mp_set_avopts_pos(log, avobj, avobj, kv);
  371|  32.7k|}
mp_set_avopts_pos:
  376|  32.7k|{
  377|  32.7k|    int success = 0;
  378|  32.7k|    for (int n = 0; kv && kv[n * 2]; n++) {
  ------------------
  |  Branch (378:21): [True: 0, False: 32.7k]
  |  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|  32.7k|    return success;
  394|  32.7k|}
mp_free_av_packet:
  405|  77.1k|{
  406|  77.1k|    if (*pkt) {
  ------------------
  |  Branch (406:9): [True: 44.5k, False: 32.5k]
  ------------------
  407|  44.5k|        (*pkt)->side_data = NULL;
  408|  44.5k|        (*pkt)->side_data_elems = 0;
  409|       |        (*pkt)->buf = NULL;
  410|  44.5k|    }
  411|  77.1k|    av_packet_free(pkt);
  412|  77.1k|}
mp_codec_info_from_av:
  415|   818k|{
  416|   818k|    c->codec_profile = av_get_profile_name(avctx->codec, avctx->profile);
  417|   818k|    if (!c->codec_profile)
  ------------------
  |  Branch (417:9): [True: 818k, False: 0]
  ------------------
  418|   818k|        c->codec_profile = avcodec_profile_name(avctx->codec_id, avctx->profile);
  419|   818k|    c->codec = avctx->codec_descriptor->name;
  420|   818k|    c->codec_desc = avctx->codec_descriptor->long_name;
  421|   818k|    c->decoder = avctx->codec->name;
  422|   818k|    c->decoder_desc = avctx->codec->long_name;
  423|   818k|}
mp_codec_info_from_avcodecpar:
  426|  80.1k|{
  427|  80.1k|    const AVCodec *codec = avcodec_find_decoder(avcodecpar->codec_id);
  428|  80.1k|    const AVCodecDescriptor *desc = avcodec_descriptor_get(avcodecpar->codec_id);
  429|  80.1k|    c->codec = mp_codec_from_av_codec_id(avcodecpar->codec_id);
  430|  80.1k|    if (desc)
  ------------------
  |  Branch (430:9): [True: 57.2k, False: 22.8k]
  ------------------
  431|  57.2k|        c->codec_desc = desc->long_name;
  432|  80.1k|    if (codec) {
  ------------------
  |  Branch (432:9): [True: 53.8k, False: 26.2k]
  ------------------
  433|  53.8k|        c->decoder = codec->name;
  434|  53.8k|        c->decoder_desc = codec->long_name;
  435|  53.8k|        c->codec_profile = av_get_profile_name(codec, avcodecpar->profile);
  436|  53.8k|    }
  437|  80.1k|    if (!c->codec_profile)
  ------------------
  |  Branch (437:9): [True: 77.0k, False: 3.07k]
  ------------------
  438|  77.0k|        c->codec_profile = avcodec_profile_name(avcodecpar->codec_id, avcodecpar->profile);
  439|  80.1k|}
av_common.c:get_def_tb:
  156|  6.13M|{
  157|  6.13M|    return tb && tb->num > 0 && tb->den > 0 ? *tb : AV_TIME_BASE_Q;
  ------------------
  |  Branch (157:12): [True: 6.13M, False: 18.4E]
  |  Branch (157:18): [True: 6.13M, False: 18.4E]
  |  Branch (157:33): [True: 6.13M, False: 9]
  ------------------
  158|  6.13M|}
av_common.c:add_codecs:
  227|  32.5k|{
  228|  32.5k|    void *iter = NULL;
  229|  16.3M|    for (;;) {
  230|  16.3M|        const AVCodec *cur = av_codec_iterate(&iter);
  231|  16.3M|        if (!cur)
  ------------------
  |  Branch (231:13): [True: 32.5k, False: 16.2M]
  ------------------
  232|  32.5k|            break;
  233|  16.2M|        if (av_codec_is_decoder(cur) == decoders &&
  ------------------
  |  Branch (233:13): [True: 16.2M, False: 0]
  ------------------
  234|  16.2M|            (type == AVMEDIA_TYPE_UNKNOWN || cur->type == type))
  ------------------
  |  Branch (234:14): [True: 0, False: 16.2M]
  |  Branch (234:46): [True: 8.32M, False: 7.96M]
  ------------------
  235|  8.32M|        {
  236|  8.32M|            mp_add_decoder(list, mp_codec_from_av_codec_id(cur->id),
  237|  8.32M|                           cur->name, cur->long_name);
  238|  8.32M|        }
  239|  16.2M|    }
  240|  32.5k|}

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

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

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

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

mp_msg_level:
  184|  30.5M|{
  185|  30.5M|    struct mp_log_root *root = log->root;
  186|  30.5M|    if (!root)
  ------------------
  |  Branch (186:9): [True: 992k, False: 29.5M]
  ------------------
  187|   992k|        return -1;
  188|  29.5M|    if (atomic_load_explicit(&log->reload_counter, memory_order_relaxed) !=
  ------------------
  |  Branch (188:9): [True: 780k, False: 28.7M]
  ------------------
  189|  29.5M|        atomic_load_explicit(&root->reload_counter, memory_order_relaxed))
  190|   780k|    {
  191|   780k|        update_loglevel(log);
  192|   780k|    }
  193|       |    return atomic_load_explicit(&log->level, memory_order_relaxed);
  194|  30.5M|}
mp_msg_flush_status_line:
  295|  65.0k|{
  296|  65.0k|    if (!log->root)
  ------------------
  |  Branch (296:9): [True: 0, False: 65.0k]
  ------------------
  297|      0|        return;
  298|       |
  299|  65.0k|    mp_mutex_lock(&log->root->lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  300|  65.0k|    msg_flush_status_line(log->root, clear);
  301|  65.0k|    mp_mutex_unlock(&log->root->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  302|  65.0k|}
mp_msg_sanitize:
  576|  14.0M|{
  577|   745M|    for (size_t i = 0; i < text->len; i++) {
  ------------------
  |  Branch (577:24): [True: 731M, False: 14.0M]
  ------------------
  578|   731M|        unsigned char ch = text->start[i];
  579|       |
  580|       |        // Allow SGR escape sequences only, filter anything else.
  581|   731M|        if (allow_sgr && ch == 0x1B && i + 2 < text->len && text->start[i + 1] == '[') {
  ------------------
  |  Branch (581:13): [True: 731M, False: 0]
  |  Branch (581:26): [True: 5.05k, False: 731M]
  |  Branch (581:40): [True: 4.95k, False: 99]
  |  Branch (581:61): [True: 285, False: 4.67k]
  ------------------
  582|    285|            size_t j = i + 2;
  583|    285|            bool sgr = false;
  584|       |
  585|  2.76k|            while (j < text->len) {
  ------------------
  |  Branch (585:20): [True: 2.75k, False: 4]
  ------------------
  586|  2.75k|                unsigned char c = text->start[j];
  587|  2.75k|                if (c == 'm') {
  ------------------
  |  Branch (587:21): [True: 67, False: 2.69k]
  ------------------
  588|     67|                    sgr = true;
  589|     67|                    i = j;
  590|     67|                    break;
  591|  2.69k|                } else if ((c >= '0' && c <= '9') || c == ';' || c == ':') {
  ------------------
  |  Branch (591:29): [True: 2.57k, False: 114]
  |  Branch (591:41): [True: 737, False: 1.84k]
  |  Branch (591:54): [True: 95, False: 1.86k]
  |  Branch (591:66): [True: 1.64k, False: 214]
  ------------------
  592|  2.47k|                    j++;
  593|  2.47k|                } else {
  594|    214|                    break;
  595|    214|                }
  596|  2.75k|            }
  597|       |
  598|       |            // Nuke everything that is not an SGR sequence
  599|    285|            if (!sgr)
  ------------------
  |  Branch (599:17): [True: 218, False: 67]
  ------------------
  600|    218|                text->start[i] = '?';
  601|    285|            continue;
  602|    285|        }
  603|       |
  604|   731M|        int len = bstr_parse_utf8_code_length(ch);
  605|       |
  606|       |        // ASCII: allow only printable plus HT, LF, CR.
  607|   731M|        if (len == 1) {
  ------------------
  |  Branch (607:13): [True: 730M, False: 1.33M]
  ------------------
  608|   730M|            if (ch == 0x7F || (ch < 0x20 && ch != '\t' && ch != '\n' && ch != '\r'))
  ------------------
  |  Branch (608:17): [True: 12.7k, False: 730M]
  |  Branch (608:32): [True: 13.3M, False: 716M]
  |  Branch (608:45): [True: 13.3M, False: 16.6k]
  |  Branch (608:59): [True: 238k, False: 13.1M]
  |  Branch (608:73): [True: 210k, False: 28.1k]
  ------------------
  609|   223k|                text->start[i] = '?';
  610|   730M|            continue;
  611|   730M|        }
  612|       |
  613|       |        // Block UTF-8 C1 controls (C2 80..C2 9F), except PU1/PU2 used internally.
  614|  1.33M|        if (ch == 0xC2 && i + 1 < text->len && (text->start[i + 1] & 0xC0) == 0x80) {
  ------------------
  |  Branch (614:13): [True: 394k, False: 943k]
  |  Branch (614:27): [True: 394k, False: 22]
  |  Branch (614:48): [True: 393k, False: 927]
  ------------------
  615|   393k|            unsigned char c1 = text->start[i + 1];
  616|   393k|            if (c1 >= 0x80 && c1 <= 0x9F && c1 != 0x91 && c1 != 0x92) {
  ------------------
  |  Branch (616:17): [True: 393k, False: 0]
  |  Branch (616:31): [True: 23.8k, False: 369k]
  |  Branch (616:45): [True: 20.6k, False: 3.17k]
  |  Branch (616:59): [True: 19.6k, False: 1.04k]
  ------------------
  617|  19.6k|                text->start[i] = '?';
  618|  19.6k|                text->start[i + 1] = '?';
  619|  19.6k|            }
  620|   393k|            i++;
  621|   393k|            continue;
  622|   393k|        }
  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|   944k|        if (len >= 2 && ch >= 0xC2 && i + len <= text->len) {
  ------------------
  |  Branch (626:13): [True: 600k, False: 344k]
  |  Branch (626:25): [True: 583k, False: 17.5k]
  |  Branch (626:39): [True: 580k, False: 2.73k]
  ------------------
  627|   580k|            bool valid = true;
  628|  1.53M|            for (int n = 1; n < len; n++)
  ------------------
  |  Branch (628:29): [True: 957k, False: 580k]
  ------------------
  629|   957k|                valid &= (text->start[i + n] & 0xC0) == 0x80;
  630|   580k|            if (valid) {
  ------------------
  |  Branch (630:17): [True: 501k, False: 78.5k]
  ------------------
  631|   501k|                i += len - 1;
  632|   501k|                continue;
  633|   501k|            }
  634|   580k|        }
  635|       |
  636|       |        // Block raw 8-bit C1 (0x80-0x9F); leave other invalid bytes alone.
  637|   442k|        if (ch <= 0x9F)
  ------------------
  |  Branch (637:13): [True: 109k, False: 333k]
  ------------------
  638|   109k|            text->start[i] = '?';
  639|   442k|    }
  640|  14.0M|}
mp_msg_va:
  654|  26.1M|{
  655|  26.1M|    if (!mp_msg_test(log, lev))
  ------------------
  |  Branch (655:9): [True: 12.1M, False: 14.0M]
  ------------------
  656|  12.1M|        return; // do not display
  657|       |
  658|  14.0M|    struct mp_log_root *root = log->root;
  659|       |
  660|  14.0M|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  14.0M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  661|       |
  662|  14.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|  14.0M|    size_t sanitized = utf8_tail_start(log->partial[lev]);
  667|  14.0M|    if (log->partial[lev].len)
  ------------------
  |  Branch (667:9): [True: 1.51M, False: 12.5M]
  ------------------
  668|  1.51M|        bstr_xappend(root, &root->buffer, log->partial[lev]);
  669|  14.0M|    log->partial[lev].len = 0;
  670|       |
  671|  14.0M|    if (bstr_xappend_vasprintf(root, &root->buffer, format, va) < 0) {
  ------------------
  |  Branch (671:9): [True: 0, False: 14.0M]
  ------------------
  672|      0|        bstr_xappend(root, &root->buffer, bstr0("format error: "));
  673|      0|        bstr_xappend(root, &root->buffer, bstr0(format));
  674|      0|    }
  675|       |
  676|  14.0M|    bstr text = {root->buffer.start + sanitized, root->buffer.len - sanitized};
  677|  14.0M|    mp_msg_sanitize(&text, true);
  678|       |
  679|       |    // Remember last status message and restore it to ensure that it is
  680|       |    // always displayed
  681|  14.0M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (681:9): [True: 0, False: 14.0M]
  ------------------
  682|      0|        root->status_log = log;
  683|      0|        root->status_line.len = 0;
  684|       |        // Use bstr_xappend instead bstrdup to reuse allocated memory
  685|      0|        if (root->buffer.len)
  ------------------
  |  Branch (685:13): [True: 0, False: 0]
  ------------------
  686|      0|            bstr_xappend(root, &root->status_line, root->buffer);
  687|      0|    }
  688|       |
  689|  14.0M|    if (lev == MSGL_STATS) {
  ------------------
  |  Branch (689:9): [True: 0, False: 14.0M]
  ------------------
  690|      0|        dump_stats(log, lev, root->buffer);
  691|  14.0M|    } else if (lev == MSGL_STATUS && !test_terminal_level(log, lev)) {
  ------------------
  |  Branch (691:16): [True: 0, False: 14.0M]
  |  Branch (691:38): [True: 0, False: 0]
  ------------------
  692|       |        /* discard */
  693|  14.0M|    } else {
  694|  14.0M|        write_term_msg(log, lev, root->buffer, &root->term_msg);
  695|       |
  696|  14.0M|        FILE *stream = term_msg_fp(root, lev);
  697|  14.0M|        if (root->term_msg.len) {
  ------------------
  |  Branch (697:13): [True: 0, False: 14.0M]
  ------------------
  698|      0|            root->term_status_msg.len = 0;
  699|      0|            if (lev != MSGL_STATUS && root->status_line.len && root->status_log &&
  ------------------
  |  Branch (699:17): [True: 0, False: 0]
  |  Branch (699:39): [True: 0, False: 0]
  |  Branch (699:64): [True: 0, False: 0]
  ------------------
  700|      0|                is_status_output(root, lev) && test_terminal_level(root->status_log, MSGL_STATUS))
  ------------------
  |  Branch (700:17): [True: 0, False: 0]
  |  Branch (700:48): [True: 0, False: 0]
  ------------------
  701|      0|            {
  702|      0|                write_term_msg(root->status_log, MSGL_STATUS, root->status_line,
  703|      0|                               &root->term_status_msg);
  704|      0|            }
  705|      0|            terminal_lock_output();
  706|      0|            fwrite(root->term_msg.start, root->term_msg.len, 1, stream);
  707|      0|            if (root->term_status_msg.len)
  ------------------
  |  Branch (707:17): [True: 0, False: 0]
  ------------------
  708|      0|                fwrite(root->term_status_msg.start, root->term_status_msg.len, 1, stream);
  709|      0|            fflush(stream);
  710|      0|            terminal_unlock_output();
  711|      0|        }
  712|  14.0M|    }
  713|       |
  714|  14.0M|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  14.0M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  715|  14.0M|}
mp_log_new:
  737|  1.89M|{
  738|  1.89M|    mp_assert(parent);
  ------------------
  |  |   41|  1.89M|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 1.89M, False: 0]
  ------------------
  739|  1.89M|    struct mp_log *log = talloc_zero(talloc_ctx, struct mp_log);
  ------------------
  |  |   27|  1.89M|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  1.89M|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.89M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|  1.89M|    if (!parent->root)
  ------------------
  |  Branch (740:9): [True: 0, False: 1.89M]
  ------------------
  741|      0|        return log; // same as null_log
  742|  1.89M|    talloc_set_destructor(log, destroy_log);
  ------------------
  |  |   41|  1.89M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  743|  1.89M|    log->root = parent->root;
  744|  1.89M|    log->max_level = MSGL_MAX;
  745|  1.89M|    if (name) {
  ------------------
  |  Branch (745:9): [True: 1.86M, False: 32.5k]
  ------------------
  746|  1.86M|        if (name[0] == '!') {
  ------------------
  |  Branch (746:13): [True: 227k, False: 1.63M]
  ------------------
  747|   227k|            name = &name[1];
  748|  1.63M|        } else if (name[0] == '/') {
  ------------------
  |  Branch (748:20): [True: 0, False: 1.63M]
  ------------------
  749|      0|            name = &name[1];
  750|      0|            log->prefix = talloc_strdup(log, name);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  751|  1.63M|        } else {
  752|  1.63M|            log->prefix = parent->prefix
  ------------------
  |  Branch (752:27): [True: 175k, False: 1.45M]
  ------------------
  753|  1.63M|                    ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   175k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   175k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  754|  1.63M|                    : talloc_strdup(log, name);
  ------------------
  |  |   50|  1.45M|#define talloc_strdup                   ta_xstrdup
  ------------------
  755|  1.63M|        }
  756|  1.86M|        log->verbose_prefix = parent->prefix
  ------------------
  |  Branch (756:31): [True: 175k, False: 1.68M]
  ------------------
  757|  1.86M|                ? talloc_asprintf(log, "%s/%s", parent->prefix, name)
  ------------------
  |  |   52|   175k|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|   175k|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
  758|  1.86M|                : talloc_strdup(log, name);
  ------------------
  |  |   50|  1.68M|#define talloc_strdup                   ta_xstrdup
  ------------------
  759|  1.86M|        if (log->prefix && !log->prefix[0])
  ------------------
  |  Branch (759:13): [True: 1.63M, False: 227k]
  |  Branch (759:28): [True: 32.5k, False: 1.60M]
  ------------------
  760|  32.5k|            log->prefix = NULL;
  761|  1.86M|        if (!log->verbose_prefix[0])
  ------------------
  |  Branch (761:13): [True: 32.5k, False: 1.83M]
  ------------------
  762|  32.5k|            log->verbose_prefix = "global";
  763|  1.86M|    } else {
  764|  32.5k|        log->prefix = talloc_strdup(log, parent->prefix);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  765|  32.5k|        log->verbose_prefix = talloc_strdup(log, parent->verbose_prefix);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  766|  32.5k|    }
  767|  1.89M|    return log;
  768|  1.89M|}
mp_msg_init:
  771|  32.5k|{
  772|  32.5k|    mp_assert(!global->log);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (772:5): [True: 32.5k, False: 0]
  ------------------
  773|       |
  774|  32.5k|    struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root);
  ------------------
  |  |   27|  32.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  32.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  775|  32.5k|    *root = (struct mp_log_root){
  776|  32.5k|        .global = global,
  777|  32.5k|        .reload_counter = 1,
  778|  32.5k|    };
  779|       |
  780|  32.5k|    mp_mutex_init(&root->lock);
  781|  32.5k|    mp_mutex_init(&root->log_file_lock);
  782|  32.5k|    mp_cond_init(&root->log_file_wakeup);
  783|       |
  784|  32.5k|    struct mp_log dummy = { .root = root };
  785|  32.5k|    struct mp_log *log = mp_log_new(root, &dummy, "");
  786|       |
  787|  32.5k|    global->log = log;
  788|  32.5k|}
mp_msg_update_msglevels:
  881|  65.0k|{
  882|  65.0k|    struct mp_log_root *root = global->log->root;
  883|       |
  884|  65.0k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  885|       |
  886|  65.0k|    root->verbose = opts->verbose;
  887|  65.0k|    root->really_quiet = opts->msg_really_quiet;
  888|  65.0k|    root->module = opts->msg_module;
  889|  65.0k|    root->use_terminal = opts->use_terminal;
  890|  65.0k|    root->show_time = opts->msg_time;
  891|       |
  892|  65.0k|    if (root->really_quiet)
  ------------------
  |  Branch (892:9): [True: 0, False: 65.0k]
  ------------------
  893|      0|        root->status_lines = 0;
  894|       |
  895|  65.0k|    for (int i = STDOUT_FILENO; i <= STDERR_FILENO && root->use_terminal; ++i) {
  ------------------
  |  Branch (895:33): [True: 65.0k, False: 0]
  |  Branch (895:55): [True: 0, False: 65.0k]
  ------------------
  896|      0|        root->isatty[i] = isatty(i);
  897|      0|        root->color[i] = opts->msg_color && root->isatty[i];
  ------------------
  |  Branch (897:26): [True: 0, False: 0]
  |  Branch (897:45): [True: 0, False: 0]
  ------------------
  898|      0|    }
  899|       |
  900|  65.0k|    m_option_type_msglevels.free(&root->msg_levels);
  901|  65.0k|    m_option_type_msglevels.copy(NULL, &root->msg_levels, &opts->msg_levels);
  902|       |
  903|  65.0k|    atomic_fetch_add(&root->reload_counter, 1);
  904|  65.0k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  905|       |
  906|  65.0k|    if (check_new_path(global, opts->log_file, &root->log_path)) {
  ------------------
  |  Branch (906:9): [True: 0, False: 65.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|  65.0k|    if (check_new_path(global, opts->dump_stats, &root->stats_path)) {
  ------------------
  |  Branch (953:9): [True: 0, False: 65.0k]
  ------------------
  954|      0|        bool open_error = false;
  955|       |
  956|      0|        mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  957|      0|        if (root->stats_file)
  ------------------
  |  Branch (957:13): [True: 0, False: 0]
  ------------------
  958|      0|            fclose(root->stats_file);
  959|      0|        root->stats_file = NULL;
  960|      0|        if (root->stats_path) {
  ------------------
  |  Branch (960:13): [True: 0, False: 0]
  ------------------
  961|      0|            root->stats_file = fopen(root->stats_path, "wb");
  ------------------
  |  |   84|      0|#define fopen(...) mp_fopen(__VA_ARGS__)
  ------------------
  962|      0|            open_error = !root->stats_file;
  963|      0|        }
  964|      0|        mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  965|       |
  966|      0|        if (open_error) {
  ------------------
  |  Branch (966:13): [True: 0, False: 0]
  ------------------
  967|      0|            mp_err(global->log, "Failed to open stats file '%s'\n",
  ------------------
  |  |   76|      0|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  968|      0|                   root->stats_path);
  969|      0|        }
  970|      0|    }
  971|  65.0k|}
mp_msg_has_log_file:
  984|   130k|{
  985|   130k|    struct mp_log_root *root = global->log->root;
  986|       |
  987|   130k|    return !!root->log_file;
  988|   130k|}
mp_msg_uninit:
  991|  32.5k|{
  992|  32.5k|    struct mp_log_root *root = global->log->root;
  993|  32.5k|    mp_msg_flush_status_line(global->log, true);
  994|  32.5k|    if (root->really_quiet && root->isatty[term_msg_fileno(root, MSGL_STATUS)]) {
  ------------------
  |  Branch (994:9): [True: 0, False: 32.5k]
  |  Branch (994:31): [True: 0, False: 0]
  ------------------
  995|      0|        terminal_lock_output();
  996|      0|        fprintf(term_msg_fp(root, MSGL_STATUS), TERM_ESC_RESTORE_CURSOR);
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  997|      0|        terminal_unlock_output();
  998|      0|    }
  999|  32.5k|    terminate_log_file_thread(root);
 1000|  32.5k|    mp_msg_log_buffer_destroy(root->early_buffer);
 1001|  32.5k|    mp_msg_log_buffer_destroy(root->early_filebuffer);
 1002|  32.5k|    mp_assert(root->num_buffers == 0);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1002:5): [True: 32.5k, False: 0]
  ------------------
 1003|  32.5k|    if (root->stats_file)
  ------------------
  |  Branch (1003:9): [True: 0, False: 32.5k]
  ------------------
 1004|      0|        fclose(root->stats_file);
 1005|  32.5k|    talloc_free(root->stats_path);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1006|  32.5k|    talloc_free(root->log_path);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1007|  32.5k|    m_option_type_msglevels.free(&root->msg_levels);
 1008|  32.5k|    mp_mutex_destroy(&root->lock);
  ------------------
  |  |  133|  32.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1009|  32.5k|    mp_mutex_destroy(&root->log_file_lock);
  ------------------
  |  |  133|  32.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1010|  32.5k|    mp_cond_destroy(&root->log_file_wakeup);
 1011|  32.5k|    talloc_free(root);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1012|       |    global->log = NULL;
 1013|  32.5k|}
mp_msg_set_early_logging:
 1061|  65.0k|{
 1062|  65.0k|    struct mp_log_root *root = global->log->root;
 1063|       |
 1064|  65.0k|    mp_msg_set_early_logging_raw(global, enable, &root->early_buffer,
 1065|  65.0k|                                 EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   48|  65.0k|#define EARLY_TERM_BUF 100
  ------------------
                                               EARLY_TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
  ------------------
  |  |   27|  65.0k|#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|  65.0k|    mp_msg_set_early_logging_raw(global, enable, &root->early_filebuffer,
 1069|  65.0k|                                 EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   54|  65.0k|#define EARLY_FILE_BUF 5000
  ------------------
                                               EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
  ------------------
  |  |   29|  65.0k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
 1070|  65.0k|}
mp_msg_log_buffer_new:
 1076|  65.0k|{
 1077|  65.0k|    struct mp_log_root *root = global->log->root;
 1078|       |
 1079|  65.0k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1080|       |
 1081|  65.0k|    if (level == MP_LOG_BUFFER_MSGL_TERM) {
  ------------------
  |  |   27|  65.0k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (1081:9): [True: 32.5k, False: 32.5k]
  ------------------
 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|  32.5k|        if (root->early_buffer) {
  ------------------
  |  Branch (1086:13): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    }
 1096|       |
 1097|  65.0k|    mp_assert(size > 0);
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (1097:5): [True: 65.0k, False: 0]
  ------------------
 1098|       |
 1099|  65.0k|    struct mp_log_buffer *buffer = talloc_ptrtype(NULL, buffer);
  ------------------
  |  |   34|  65.0k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  65.0k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  65.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|  65.0k|    *buffer = (struct mp_log_buffer) {
 1101|  65.0k|        .root = root,
 1102|  65.0k|        .level = level,
 1103|  65.0k|        .entries = talloc_array(buffer, struct mp_log_buffer_entry *, size),
  ------------------
  |  |   29|  65.0k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  65.0k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  65.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|  65.0k|        .capacity = size,
 1105|  65.0k|        .wakeup_cb = wakeup_cb,
 1106|  65.0k|        .wakeup_cb_ctx = wakeup_cb_ctx,
 1107|  65.0k|    };
 1108|       |
 1109|  65.0k|    mp_mutex_init(&buffer->lock);
 1110|       |
 1111|  65.0k|    MP_TARRAY_APPEND(root, root->buffers, root->num_buffers, buffer);
  ------------------
  |  |  105|  65.0k|    do {                                            \
  |  |  106|  65.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  65.0k|    do {                                            \
  |  |  |  |   97|  65.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  65.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  65.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  65.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 32.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  65.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  65.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 65.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  65.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  65.0k|        (idxvar)++;                                 \
  |  |  109|  65.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 65.0k]
  |  |  ------------------
  ------------------
 1112|       |
 1113|  65.0k|    atomic_fetch_add(&root->reload_counter, 1);
 1114|  65.0k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|       |
 1116|  65.0k|    return buffer;
 1117|  65.0k|}
mp_msg_log_buffer_destroy:
 1161|   227k|{
 1162|   227k|    if (!buffer)
  ------------------
  |  Branch (1162:9): [True: 162k, False: 65.0k]
  ------------------
 1163|   162k|        return;
 1164|       |
 1165|  65.0k|    struct mp_log_root *root = buffer->root;
 1166|       |
 1167|  65.0k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1168|       |
 1169|  65.0k|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (1169:21): [True: 65.0k, False: 0]
  ------------------
 1170|  65.0k|        if (root->buffers[n] == buffer) {
  ------------------
  |  Branch (1170:13): [True: 65.0k, False: 0]
  ------------------
 1171|  65.0k|            MP_TARRAY_REMOVE_AT(root->buffers, root->num_buffers, n);
  ------------------
  |  |  143|  65.0k|    do {                                            \
  |  |  144|  65.0k|        size_t at_ = (at);                          \
  |  |  145|  65.0k|        assert(at_ < (idxvar));                     \
  |  |  146|  65.0k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  65.0k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  65.0k|        (idxvar)--;                                 \
  |  |  149|  65.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 65.0k]
  |  |  ------------------
  ------------------
  |  Branch (1171:13): [True: 65.0k, False: 0]
  ------------------
 1172|  65.0k|            goto found;
 1173|  65.0k|        }
 1174|  65.0k|    }
 1175|       |
 1176|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (1176:5): [Folded, False: 0]
  ------------------
 1177|       |
 1178|  65.0k|found:
 1179|       |
 1180|  1.30M|    while (buffer->num_entries)
  ------------------
  |  Branch (1180:12): [True: 1.23M, False: 65.0k]
  ------------------
 1181|  1.23M|        talloc_free(log_buffer_read(buffer));
  ------------------
  |  |   47|  1.23M|#define talloc_free                     ta_free
  ------------------
 1182|       |
 1183|  65.0k|    mp_mutex_destroy(&buffer->lock);
  ------------------
  |  |  133|  65.0k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1184|  65.0k|    talloc_free(buffer);
  ------------------
  |  |   47|  65.0k|#define talloc_free                     ta_free
  ------------------
 1185|       |
 1186|  65.0k|    atomic_fetch_add(&root->reload_counter, 1);
 1187|  65.0k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1188|  65.0k|}
mp_msg:
 1223|  26.0M|{
 1224|  26.0M|    va_list va;
 1225|  26.0M|    va_start(va, format);
 1226|  26.0M|    mp_msg_va(log, lev, format, va);
 1227|       |    va_end(va);
 1228|  26.0M|}
mp_msg_find_level:
 1255|   748k|{
 1256|  5.98M|    for (int n = 0; n < MP_ARRAY_SIZE(mp_log_levels); n++) {
  ------------------
  |  |   49|  5.98M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (1256:21): [True: 5.98M, False: 0]
  ------------------
 1257|  5.98M|        if (mp_log_levels[n] && !strcasecmp(s, mp_log_levels[n]))
  ------------------
  |  Branch (1257:13): [True: 5.98M, False: 0]
  |  Branch (1257:33): [True: 748k, False: 5.23M]
  ------------------
 1258|   748k|            return n;
 1259|  5.98M|    }
 1260|      0|    return -1;
 1261|   748k|}
msg.c:update_loglevel:
  141|   780k|{
  142|   780k|    struct mp_log_root *root = log->root;
  143|   780k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|   780k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  144|   780k|    int level = MSGL_STATUS + root->verbose; // default log level
  145|   780k|    if (root->really_quiet)
  ------------------
  |  Branch (145:9): [True: 0, False: 780k]
  ------------------
  146|      0|        level = -1;
  147|  1.49M|    for (int n = 0; root->msg_levels && root->msg_levels[n * 2 + 0]; n++) {
  ------------------
  |  Branch (147:21): [True: 1.43M, False: 65.0k]
  |  Branch (147:41): [True: 715k, False: 715k]
  ------------------
  148|   715k|        if (match_mod(log->verbose_prefix, root->msg_levels[n * 2 + 0]))
  ------------------
  |  Branch (148:13): [True: 715k, False: 0]
  ------------------
  149|   715k|            level = mp_msg_find_level(root->msg_levels[n * 2 + 1]);
  150|   715k|    }
  151|   780k|    log->terminal_level = level;
  152|  1.10M|    for (int n = 0; n < log->root->num_buffers; n++) {
  ------------------
  |  Branch (152:21): [True: 325k, False: 780k]
  ------------------
  153|   325k|        int buffer_level = log->root->buffers[n]->level;
  154|   325k|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|   325k|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (154:13): [True: 162k, False: 162k]
  ------------------
  155|   162k|            buffer_level = MSGL_DEBUG;
  156|   325k|        if (buffer_level != MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|   325k|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (156:13): [True: 162k, False: 162k]
  ------------------
  157|   162k|            level = MPMAX(level, buffer_level);
  ------------------
  |  |   44|   162k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 162k, False: 0]
  |  |  ------------------
  ------------------
  158|   325k|    }
  159|   780k|    if (log->root->log_file)
  ------------------
  |  Branch (159:9): [True: 0, False: 780k]
  ------------------
  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|   780k|    if (log->root->stats_file)
  ------------------
  |  Branch (161:9): [True: 0, False: 780k]
  ------------------
  162|      0|        level = MPMAX(level, MSGL_STATS);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  163|   780k|    level = MPMIN(level, log->max_level);
  ------------------
  |  |   45|   780k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 780k]
  |  |  ------------------
  ------------------
  164|   780k|    atomic_store_explicit(&log->level, level, memory_order_relaxed);
  165|   780k|    atomic_store(&log->reload_counter, atomic_load(&log->root->reload_counter));
  166|   780k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|   780k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  167|   780k|}
msg.c:match_mod:
  132|   715k|{
  133|   715k|    if (!strcmp(mod, "all"))
  ------------------
  |  Branch (133:9): [True: 715k, False: 0]
  ------------------
  134|   715k|        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|   715k|}
msg.c:msg_flush_status_line:
  265|  65.0k|{
  266|  65.0k|    if (!root->status_lines)
  ------------------
  |  Branch (266:9): [True: 65.0k, False: 0]
  ------------------
  267|  65.0k|        goto done;
  268|       |
  269|      0|    FILE *fp = term_msg_fp(root, MSGL_STATUS);
  270|      0|    if (!clear) {
  ------------------
  |  Branch (270:9): [True: 0, False: 0]
  ------------------
  271|      0|        terminal_lock_output();
  272|      0|        if (root->isatty[term_msg_fileno(root, MSGL_STATUS)])
  ------------------
  |  Branch (272:13): [True: 0, False: 0]
  ------------------
  273|      0|            fprintf(fp, TERM_ESC_RESTORE_CURSOR);
  ------------------
  |  |   30|      0|#define TERM_ESC_RESTORE_CURSOR     "\033[?25h"
  ------------------
  274|      0|        fprintf(fp, "\n");
  275|      0|        terminal_unlock_output();
  276|      0|        root->blank_lines = 0;
  277|      0|        root->status_lines = 0;
  278|      0|        goto done;
  279|      0|    }
  280|       |
  281|      0|    bstr term_msg = {0};
  282|      0|    prepare_prefix(root, &term_msg, MSGL_STATUS, 0);
  283|      0|    if (term_msg.len) {
  ------------------
  |  Branch (283:9): [True: 0, False: 0]
  ------------------
  284|      0|        terminal_lock_output();
  285|      0|        fprintf(fp, "%.*s", BSTR_P(term_msg));
  ------------------
  |  |  307|      0|#define BSTR_P(bstr) (int)((bstr).len), ((bstr).start ? (char*)(bstr).start : "")
  |  |  ------------------
  |  |  |  Branch (307:42): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  286|      0|        terminal_unlock_output();
  287|      0|        talloc_free(term_msg.start);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  288|      0|    }
  289|       |
  290|  65.0k|done:
  291|  65.0k|    root->status_line.len = 0;
  292|  65.0k|}
msg.c:term_msg_fp:
  202|  14.0M|{
  203|  14.0M|    return term_msg_fileno(root, lev) == STDERR_FILENO ? stderr : stdout;
  ------------------
  |  Branch (203:12): [True: 0, False: 14.0M]
  ------------------
  204|  14.0M|}
msg.c:utf8_tail_start:
  644|  14.0M|{
  645|  14.0M|    for (size_t n = 1; n <= 4 && n <= str.len; n++) {
  ------------------
  |  Branch (645:24): [True: 14.0M, False: 22]
  |  Branch (645:34): [True: 1.52M, False: 12.5M]
  ------------------
  646|  1.52M|        unsigned char ch = str.start[str.len - n];
  647|  1.52M|        if ((ch & 0xC0) != 0x80)
  ------------------
  |  Branch (647:13): [True: 1.51M, False: 1.64k]
  ------------------
  648|  1.51M|            return ch >= 0xC0 ? str.len - n : str.len;
  ------------------
  |  Branch (648:20): [True: 25.3k, False: 1.49M]
  ------------------
  649|  1.52M|    }
  650|  12.5M|    return str.len;
  651|  14.0M|}
msg.c:test_terminal_level:
  379|  14.0M|{
  380|  14.0M|    return lev <= log->terminal_level && log->root->use_terminal &&
  ------------------
  |  Branch (380:12): [True: 14.0M, False: 0]
  |  Branch (380:42): [True: 0, False: 14.0M]
  ------------------
  381|      0|           !(lev == MSGL_STATUS && terminal_in_background());
  ------------------
  |  Branch (381:14): [True: 0, False: 0]
  |  Branch (381:36): [True: 0, False: 0]
  ------------------
  382|  14.0M|}
msg.c:write_term_msg:
  518|  14.0M|{
  519|  14.0M|    struct mp_log_root *root = log->root;
  520|  14.0M|    bool print_term = test_terminal_level(log, lev);
  521|  14.0M|    int fileno = term_msg_fileno(root, lev);
  522|  14.0M|    int term_w = 0, term_h = 0;
  523|  14.0M|    if (print_term && root->isatty[fileno])
  ------------------
  |  Branch (523:9): [True: 0, False: 14.0M]
  |  Branch (523:23): [True: 0, False: 0]
  ------------------
  524|      0|        terminal_get_size(&term_w, &term_h);
  525|       |
  526|  14.0M|    out->len = 0;
  527|       |
  528|       |    // Split away each line. Normally we require full lines; buffer partial
  529|       |    // lines if they happen.
  530|  14.0M|    root->term_msg_tmp.len = 0;
  531|  14.0M|    int term_msg_lines = 0;
  532|       |
  533|  14.0M|    bstr str = text;
  534|  27.1M|    while (str.len) {
  ------------------
  |  Branch (534:12): [True: 14.6M, False: 12.5M]
  ------------------
  535|  14.6M|        bstr line = bstr_getline(str, &str);
  536|  14.6M|        if (line.start[line.len - 1] != '\n') {
  ------------------
  |  Branch (536:13): [True: 1.51M, False: 13.1M]
  ------------------
  537|  1.51M|            mp_assert(str.len == 0);
  ------------------
  |  |   41|  1.51M|#define mp_assert assert
  ------------------
  |  Branch (537:13): [True: 1.51M, False: 0]
  ------------------
  538|  1.51M|            str = line;
  539|  1.51M|            break;
  540|  1.51M|        }
  541|       |
  542|  14.6M|        bool clip = bstr_eatstart0(&line, TERM_MSG_0);
  ------------------
  |  |   30|  13.1M|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|  13.1M|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  543|  13.1M|        if (print_term) {
  ------------------
  |  Branch (543:13): [True: 0, False: 13.1M]
  ------------------
  544|      0|            int line_w;
  545|      0|            append_terminal_line(log, lev, line, &root->term_msg_tmp, &line_w,
  546|      0|                                 clip && term_w ? term_w : INT_MAX);
  ------------------
  |  Branch (546:34): [True: 0, False: 0]
  |  Branch (546:42): [True: 0, False: 0]
  ------------------
  547|      0|            term_msg_lines += (!line_w || !term_w)
  ------------------
  |  Branch (547:32): [True: 0, False: 0]
  |  Branch (547:43): [True: 0, False: 0]
  ------------------
  548|      0|                                ? 1 : (line_w + term_w - 1) / term_w;
  549|      0|        }
  550|  13.1M|        write_msg_to_buffers(log, lev, line);
  551|  13.1M|    }
  552|       |
  553|  14.0M|    if (lev == MSGL_STATUS) {
  ------------------
  |  Branch (553:9): [True: 0, False: 14.0M]
  ------------------
  554|      0|        int line_w = 0;
  555|      0|        bool clip = bstr_eatstart0(&str, TERM_MSG_0);
  ------------------
  |  |   30|      0|#define TERM_MSG_0 TERM_MSG_ESCAPE "0"
  |  |  ------------------
  |  |  |  |   29|      0|#define TERM_MSG_ESCAPE "\xC2\x92" "t"
  |  |  ------------------
  ------------------
  556|      0|        if (str.len && print_term)
  ------------------
  |  Branch (556:13): [True: 0, False: 0]
  |  Branch (556:24): [True: 0, False: 0]
  ------------------
  557|      0|            append_terminal_line(log, lev, str, &root->term_msg_tmp, &line_w,
  558|      0|                                 clip && term_w ? term_w : INT_MAX);
  ------------------
  |  Branch (558:34): [True: 0, False: 0]
  |  Branch (558:42): [True: 0, False: 0]
  ------------------
  559|      0|        term_msg_lines += !term_w ? (str.len ? 1 : 0)
  ------------------
  |  Branch (559:27): [True: 0, False: 0]
  |  Branch (559:38): [True: 0, False: 0]
  ------------------
  560|      0|                                  : (line_w + term_w - 1) / term_w;
  561|  14.0M|    } else if (str.len) {
  ------------------
  |  Branch (561:16): [True: 1.51M, False: 12.5M]
  ------------------
  562|  1.51M|        bstr_xappend(NULL, &log->partial[lev], str);
  563|  1.51M|    }
  564|       |
  565|  14.0M|    if (print_term && (root->term_msg_tmp.len || lev == MSGL_STATUS)) {
  ------------------
  |  Branch (565:9): [True: 0, False: 14.0M]
  |  Branch (565:24): [True: 0, False: 0]
  |  Branch (565:50): [True: 0, False: 0]
  ------------------
  566|      0|        prepare_prefix(root, out, lev, term_msg_lines);
  567|      0|        if (root->color[fileno] && root->term_msg_tmp.len) {
  ------------------
  |  Branch (567:13): [True: 0, False: 0]
  |  Branch (567:36): [True: 0, False: 0]
  ------------------
  568|      0|            set_msg_color(root, out, lev);
  569|      0|            set_term_color(root, &root->term_msg_tmp, -1);
  570|      0|        }
  571|      0|        bstr_xappend(root, out, root->term_msg_tmp);
  572|      0|    }
  573|  14.0M|}
msg.c:write_msg_to_buffers:
  459|  13.1M|{
  460|  13.1M|    struct mp_log_root *root = log->root;
  461|  14.3M|    for (int n = 0; n < root->num_buffers; n++) {
  ------------------
  |  Branch (461:21): [True: 1.23M, False: 13.1M]
  ------------------
  462|  1.23M|        struct mp_log_buffer *buffer = root->buffers[n];
  463|  1.23M|        bool wakeup = false;
  464|  1.23M|        mp_mutex_lock(&buffer->lock);
  ------------------
  |  |  134|  1.23M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  465|  1.23M|        int buffer_level = buffer->level;
  466|  1.23M|        if (buffer_level == MP_LOG_BUFFER_MSGL_TERM)
  ------------------
  |  |   27|  1.23M|#define MP_LOG_BUFFER_MSGL_TERM (MSGL_MAX + 1)
  ------------------
  |  Branch (466:13): [True: 617k, False: 617k]
  ------------------
  467|   617k|            buffer_level = log->terminal_level;
  468|  1.23M|        if (buffer_level == MP_LOG_BUFFER_MSGL_LOGFILE)
  ------------------
  |  |   29|  1.23M|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (468:13): [True: 617k, False: 617k]
  ------------------
  469|   617k|            buffer_level = MPMAX(log->terminal_level, MSGL_DEBUG);
  ------------------
  |  |   44|   617k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 617k, False: 0]
  |  |  ------------------
  ------------------
  470|  1.23M|        if (lev <= buffer_level && lev != MSGL_STATUS) {
  ------------------
  |  Branch (470:13): [True: 1.23M, False: 0]
  |  Branch (470:36): [True: 1.23M, False: 0]
  ------------------
  471|  1.23M|            if (buffer->level == MP_LOG_BUFFER_MSGL_LOGFILE) {
  ------------------
  |  |   29|  1.23M|#define MP_LOG_BUFFER_MSGL_LOGFILE (MSGL_MAX + 2)
  ------------------
  |  Branch (471:17): [True: 617k, False: 617k]
  ------------------
  472|       |                // If the buffer is full, block until we can write again,
  473|       |                // unless there's no write thread (died, or early filebuffer)
  474|   617k|                if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (474:21): [True: 0, False: 617k]
  ------------------
  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|   617k|            }
  487|  1.23M|            if (buffer->num_entries == buffer->capacity) {
  ------------------
  |  Branch (487:17): [True: 0, False: 1.23M]
  ------------------
  488|      0|                struct mp_log_buffer_entry *skip = log_buffer_read(buffer);
  489|      0|                talloc_free(skip);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  490|      0|                buffer->dropped += 1;
  491|      0|            }
  492|  1.23M|            struct mp_log_buffer_entry *entry = talloc_ptrtype(NULL, entry);
  ------------------
  |  |   34|  1.23M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.23M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.23M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  493|  1.23M|            *entry = (struct mp_log_buffer_entry) {
  494|  1.23M|                .prefix = talloc_strdup(entry, log->verbose_prefix),
  ------------------
  |  |   50|  1.23M|#define talloc_strdup                   ta_xstrdup
  ------------------
  495|  1.23M|                .level = lev,
  496|  1.23M|                .text = bstrdup0(entry, text),
  497|  1.23M|            };
  498|  1.23M|            int pos = (buffer->entry0 + buffer->num_entries) % buffer->capacity;
  499|  1.23M|            buffer->entries[pos] = entry;
  500|  1.23M|            buffer->num_entries += 1;
  501|  1.23M|            if (buffer->wakeup_cb && !buffer->silent)
  ------------------
  |  Branch (501:17): [True: 0, False: 1.23M]
  |  Branch (501:38): [True: 0, False: 0]
  ------------------
  502|      0|                wakeup = true;
  503|  1.23M|        }
  504|  1.23M|        mp_mutex_unlock(&buffer->lock);
  ------------------
  |  |  136|  1.23M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  505|  1.23M|        if (wakeup)
  ------------------
  |  Branch (505:13): [True: 0, False: 1.23M]
  ------------------
  506|      0|            buffer->wakeup_cb(buffer->wakeup_cb_ctx);
  507|  1.23M|    }
  508|  13.1M|}
msg.c:destroy_log:
  718|  1.89M|{
  719|  1.89M|    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|  18.9M|    for (int lvl = 0; lvl <= MSGL_MAX; ++lvl)
  ------------------
  |  Branch (722:23): [True: 17.0M, False: 1.89M]
  ------------------
  723|  17.0M|        talloc_free(log->partial[lvl].start);
  ------------------
  |  |   47|  17.0M|#define talloc_free                     ta_free
  ------------------
  724|  1.89M|}
msg.c:check_new_path:
  858|   130k|{
  859|   130k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|   130k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   130k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  860|   130k|    bool res = false;
  861|       |
  862|   130k|    char *new_path = mp_get_user_path(tmp, global, opt);
  863|   130k|    if (!new_path)
  ------------------
  |  Branch (863:9): [True: 130k, False: 0]
  ------------------
  864|   130k|        new_path = "";
  865|       |
  866|   130k|    char *old_path = *current_path ? *current_path : "";
  ------------------
  |  Branch (866:22): [True: 0, False: 130k]
  ------------------
  867|   130k|    if (strcmp(old_path, new_path) != 0) {
  ------------------
  |  Branch (867:9): [True: 0, False: 130k]
  ------------------
  868|      0|        talloc_free(*current_path);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  869|      0|        *current_path = NULL;
  870|      0|        if (new_path[0])
  ------------------
  |  Branch (870:13): [True: 0, False: 0]
  ------------------
  871|      0|            *current_path = talloc_strdup(NULL, new_path);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  872|      0|        res = true;
  873|      0|    }
  874|       |
  875|   130k|    talloc_free(tmp);
  ------------------
  |  |   47|   130k|#define talloc_free                     ta_free
  ------------------
  876|       |
  877|   130k|    return res;
  878|   130k|}
msg.c:terminate_log_file_thread:
  832|  32.5k|{
  833|  32.5k|    bool wait_terminate = false;
  834|       |
  835|  32.5k|    mp_mutex_lock(&root->log_file_lock);
  ------------------
  |  |  134|  32.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  836|  32.5k|    if (root->log_file_thread_active) {
  ------------------
  |  Branch (836:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    mp_mutex_unlock(&root->log_file_lock);
  ------------------
  |  |  136|  32.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  842|       |
  843|  32.5k|    if (wait_terminate)
  ------------------
  |  Branch (843:9): [True: 0, False: 32.5k]
  ------------------
  844|      0|        mp_thread_join(root->log_file_thread);
  ------------------
  |  |  215|      0|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
  845|       |
  846|  32.5k|    mp_msg_log_buffer_destroy(root->log_file_buffer);
  847|  32.5k|    root->log_file_buffer = NULL;
  848|       |
  849|  32.5k|    if (root->log_file)
  ------------------
  |  Branch (849:9): [True: 0, False: 32.5k]
  ------------------
  850|      0|        fclose(root->log_file);
  851|       |    root->log_file = NULL;
  852|  32.5k|}
msg.c:term_msg_fileno:
  197|  28.0M|{
  198|  28.0M|    return root->force_stderr ? STDERR_FILENO : STDOUT_FILENO;
  ------------------
  |  Branch (198:12): [True: 0, False: 28.0M]
  ------------------
  199|  28.0M|}
msg.c:mp_msg_set_early_logging_raw:
 1036|   130k|{
 1037|   130k|    struct mp_log_root *root = global->log->root;
 1038|   130k|    mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|   130k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1039|       |
 1040|   130k|    if (enable != !!*root_logbuf) {
  ------------------
  |  Branch (1040:9): [True: 130k, False: 0]
  ------------------
 1041|   130k|        if (enable) {
  ------------------
  |  Branch (1041:13): [True: 65.0k, False: 65.0k]
  ------------------
 1042|  65.0k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1043|  65.0k|            struct mp_log_buffer *buf =
 1044|  65.0k|                mp_msg_log_buffer_new(global, size, level, NULL, NULL);
 1045|  65.0k|            mp_mutex_lock(&root->lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1046|  65.0k|            mp_assert(!*root_logbuf); // no concurrent calls to this function
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (1046:13): [True: 65.0k, False: 0]
  ------------------
 1047|  65.0k|            *root_logbuf = buf;
 1048|  65.0k|        } else {
 1049|  65.0k|            struct mp_log_buffer *buf = *root_logbuf;
 1050|  65.0k|            *root_logbuf = NULL;
 1051|  65.0k|            mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1052|  65.0k|            mp_msg_log_buffer_destroy(buf);
 1053|  65.0k|            return;
 1054|  65.0k|        }
 1055|   130k|    }
 1056|       |
 1057|  65.0k|    mp_mutex_unlock(&root->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1058|  65.0k|}
msg.c:log_buffer_read:
  442|  1.23M|{
  443|  1.23M|    mp_assert(buffer->num_entries);
  ------------------
  |  |   41|  1.23M|#define mp_assert assert
  ------------------
  |  Branch (443:5): [True: 1.23M, False: 0]
  ------------------
  444|  1.23M|    struct mp_log_buffer_entry *res = buffer->entries[buffer->entry0];
  445|  1.23M|    buffer->entry0 = (buffer->entry0 + 1) % buffer->capacity;
  446|  1.23M|    buffer->num_entries -= 1;
  447|  1.23M|    return res;
  448|  1.23M|}

av_log.c:mp_msg_test:
   64|  3.87M|{
   65|  3.87M|    return lev <= mp_msg_level(log);
   66|  3.87M|}
msg.c:mp_msg_test:
   64|  26.1M|{
   65|  26.1M|    return lev <= mp_msg_level(log);
   66|  26.1M|}
cmd.c:mp_msg_test:
   64|  97.5k|{
   65|  97.5k|    return lev <= mp_msg_level(log);
   66|  97.5k|}
m_config_frontend.c:mp_msg_test:
   64|   390k|{
   65|   390k|    return lev <= mp_msg_level(log);
   66|   390k|}

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

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

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

mp_set_codec_from_tag:
  164|    193|{
  165|    193|    c->codec = lookup_tag(c->type, c->codec_tag);
  166|    193|    if (c->type == STREAM_AUDIO)
  ------------------
  |  Branch (166:9): [True: 6, False: 187]
  ------------------
  167|      6|        map_audio_pcm_tag(c);
  168|    193|}
mp_map_mimetype_to_video_codec:
  200|  15.0k|{
  201|  15.0k|    if (mimetype) {
  ------------------
  |  Branch (201:9): [True: 0, False: 15.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|  15.0k|    return NULL;
  208|  15.0k|}
codec_tags.c:lookup_tag:
   31|    193|{
   32|    193|    const struct AVCodecTag *av_tags[3] = {0};
   33|    193|    switch (type) {
  ------------------
  |  Branch (33:13): [True: 193, False: 0]
  ------------------
   34|    187|    case STREAM_VIDEO: {
  ------------------
  |  Branch (34:5): [True: 187, False: 6]
  ------------------
   35|    187|        av_tags[0] = avformat_get_riff_video_tags();
   36|    187|        av_tags[1] = avformat_get_mov_video_tags();
   37|    187|        break;
   38|      0|    }
   39|      6|    case STREAM_AUDIO: {
  ------------------
  |  Branch (39:5): [True: 6, False: 187]
  ------------------
   40|      6|        av_tags[0] = avformat_get_riff_audio_tags();
   41|      6|        av_tags[1] = avformat_get_mov_audio_tags();
   42|      6|        break;
   43|      0|    }
   44|    193|    }
   45|       |
   46|    193|    int id = av_codec_get_id(av_tags, tag);
   47|    193|    return id == AV_CODEC_ID_NONE ? NULL : mp_codec_from_av_codec_id(id);
  ------------------
  |  Branch (47:12): [True: 28, False: 165]
  ------------------
   48|    193|}
codec_tags.c:map_audio_pcm_tag:
  105|      6|{
  106|       |    // MS PCM, Extended
  107|      6|    if (c->codec_tag == 0xfffe && c->extradata_size >= 22) {
  ------------------
  |  Branch (107:9): [True: 0, False: 6]
  |  Branch (107:35): [True: 0, False: 0]
  ------------------
  108|       |        // WAVEFORMATEXTENSIBLE.wBitsPerSample
  109|      0|        int bits_per_sample = AV_RL16(c->extradata);
  110|      0|        if (bits_per_sample)
  ------------------
  |  Branch (110:13): [True: 0, False: 0]
  ------------------
  111|      0|            c->bits_per_coded_sample = bits_per_sample;
  112|       |
  113|       |        // WAVEFORMATEXTENSIBLE.dwChannelMask
  114|      0|        uint64_t chmask = AV_RL32(c->extradata + 2);
  115|      0|        struct mp_chmap chmap;
  116|      0|        mp_chmap_from_waveext(&chmap, chmask);
  ------------------
  |  |  175|      0|#define mp_chmap_from_waveext mp_chmap_from_lavc
  ------------------
  117|      0|        if (c->channels.num == chmap.num)
  ------------------
  |  Branch (117:13): [True: 0, False: 0]
  ------------------
  118|      0|            c->channels = chmap;
  119|       |
  120|       |        // WAVEFORMATEXTENSIBLE.SubFormat
  121|      0|        unsigned char *subformat = c->extradata + 6;
  122|      0|        for (int i = 0; i < MP_ARRAY_SIZE(guid_ext_base); i++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (122:25): [True: 0, False: 0]
  ------------------
  123|      0|            if (memcmp(subformat + 4, guid_ext_base[i] + 4, 12) == 0) {
  ------------------
  |  Branch (123:17): [True: 0, False: 0]
  ------------------
  124|      0|                c->codec_tag = AV_RL32(subformat);
  125|      0|                c->codec = lookup_tag(c->type, c->codec_tag);
  126|      0|                break;
  127|      0|            }
  128|      0|        }
  129|       |
  130|       |        // extra subformat, not a base one
  131|      0|        if (c->codec_tag == 0xfffe) {
  ------------------
  |  Branch (131:13): [True: 0, False: 0]
  ------------------
  132|      0|            for (int i = 0; i < MP_ARRAY_SIZE(guid_ext_other); i++) {
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (132:29): [True: 0, False: 0]
  ------------------
  133|      0|                if (memcmp(subformat, &guid_ext_other[i].guid, 16) == 0) {
  ------------------
  |  Branch (133:21): [True: 0, False: 0]
  ------------------
  134|      0|                    c->codec = guid_ext_other[i].codec;
  135|      0|                    c->codec_tag = mp_codec_to_av_codec_id(c->codec);
  136|      0|                    break;
  137|      0|                }
  138|      0|            }
  139|      0|        }
  140|       |
  141|       |        // Compressed formats might use this.
  142|      0|        c->extradata += 22;
  143|      0|        c->extradata_size -= 22;
  144|      0|    }
  145|       |
  146|      6|    int bits = c->bits_per_coded_sample;
  147|      6|    if (!bits)
  ------------------
  |  Branch (147:9): [True: 1, False: 5]
  ------------------
  148|      1|        return;
  149|       |
  150|      5|    int bytes = (bits + 7) / 8;
  151|      5|    switch (c->codec_tag) {
  ------------------
  |  Branch (151:13): [True: 0, False: 5]
  ------------------
  152|      0|    case 0x0:       // Microsoft PCM
  ------------------
  |  Branch (152:5): [True: 0, False: 5]
  ------------------
  153|      0|    case 0x1:
  ------------------
  |  Branch (153:5): [True: 0, False: 5]
  ------------------
  154|      0|        if (bytes >= 1 && bytes <= 4)
  ------------------
  |  Branch (154:13): [True: 0, False: 0]
  |  Branch (154:27): [True: 0, False: 0]
  ------------------
  155|      0|            mp_set_pcm_codec(c, bytes > 1, false, bytes * 8, false);
  156|      0|        break;
  157|      0|    case 0x3:       // IEEE float
  ------------------
  |  Branch (157:5): [True: 0, False: 5]
  ------------------
  158|      0|        mp_set_pcm_codec(c, true, true, bits == 64 ? 64 : 32, false);
  ------------------
  |  Branch (158:41): [True: 0, False: 0]
  ------------------
  159|      0|        break;
  160|      5|    }
  161|      5|}

mp_probe_cue:
  181|  40.0k|{
  182|  40.0k|    bool valid = false;
  183|  40.0k|    data = skip_utf8_bom(data);
  184|  59.0k|    for (;;) {
  185|  59.0k|        enum cue_command cmd = read_cmd(&data, NULL);
  186|       |        // End reached. Since the line was most likely cut off, don't use the
  187|       |        // result of the last parsing call.
  188|  59.0k|        if (data.len == 0)
  ------------------
  |  Branch (188:13): [True: 16.5k, False: 42.4k]
  ------------------
  189|  16.5k|            break;
  190|  42.4k|        if (cmd == CUE_ERROR)
  ------------------
  |  Branch (190:13): [True: 23.4k, False: 18.9k]
  ------------------
  191|  23.4k|            return false;
  192|  18.9k|        if (cmd != CUE_EMPTY)
  ------------------
  |  Branch (192:13): [True: 91, False: 18.8k]
  ------------------
  193|     91|            valid = true;
  194|  18.9k|    }
  195|  16.5k|    return valid;
  196|  40.0k|}
mp_parse_cue:
  199|     56|{
  200|     56|    struct cue_file *f = talloc_zero(NULL, struct cue_file);
  ------------------
  |  |   27|     56|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     56|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     56|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|     56|    f->tags = talloc_zero(f, struct mp_tags);
  ------------------
  |  |   27|     56|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|     56|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|     56|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|       |
  203|     56|    data = skip_utf8_bom(data);
  204|       |
  205|     56|    char *filename = NULL;
  206|       |    // Global metadata, and copied into new tracks.
  207|     56|    struct cue_track proto_track = {0};
  208|     56|    struct cue_track *cur_track = NULL;
  209|       |
  210|    302|    while (data.len) {
  ------------------
  |  Branch (210:12): [True: 296, False: 6]
  ------------------
  211|    296|        struct bstr param;
  212|    296|        int cmd = read_cmd(&data, &param);
  213|    296|        switch (cmd) {
  ------------------
  |  Branch (213:17): [True: 131, False: 165]
  ------------------
  214|     50|        case CUE_ERROR:
  ------------------
  |  Branch (214:9): [True: 50, False: 246]
  ------------------
  215|     50|            talloc_free(f);
  ------------------
  |  |   47|     50|#define talloc_free                     ta_free
  ------------------
  216|     50|            return NULL;
  217|      0|        case CUE_TRACK: {
  ------------------
  |  Branch (217:9): [True: 0, False: 296]
  ------------------
  218|      0|            if (bstr_find0(param, "AUDIO") == -1)
  ------------------
  |  Branch (218:17): [True: 0, False: 0]
  ------------------
  219|      0|                break;
  220|      0|            MP_TARRAY_GROW(f, f->tracks, f->num_tracks);
  ------------------
  |  |   96|      0|    do {                                            \
  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  ------------------
  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  221|      0|            f->num_tracks += 1;
  222|      0|            cur_track = &f->tracks[f->num_tracks - 1];
  223|      0|            *cur_track = proto_track;
  224|      0|            cur_track->tags = talloc_zero(f, struct mp_tags);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|      0|            break;
  226|      0|        }
  227|     13|        case CUE_TITLE:
  ------------------
  |  Branch (227:9): [True: 13, False: 283]
  ------------------
  228|     13|        case CUE_PERFORMER: {
  ------------------
  |  Branch (228:9): [True: 0, False: 296]
  ------------------
  229|     13|            static const char *metanames[] = {
  230|     13|                [CUE_TITLE] = "title",
  231|     13|                [CUE_PERFORMER] = "performer",
  232|     13|            };
  233|     13|            struct mp_tags *tags = cur_track ? cur_track->tags : f->tags;
  ------------------
  |  Branch (233:36): [True: 0, False: 13]
  ------------------
  234|     13|            mp_tags_set_bstr(tags, bstr0(metanames[cmd]), strip_quotes(param));
  235|     13|            break;
  236|     13|        }
  237|      0|        case CUE_INDEX: {
  ------------------
  |  Branch (237:9): [True: 0, False: 296]
  ------------------
  238|      0|            int type = read_int(&param, true);
  239|      0|            double time = read_time(&param);
  240|      0|            if (cur_track) {
  ------------------
  |  Branch (240:17): [True: 0, False: 0]
  ------------------
  241|      0|                if (type == 1) {
  ------------------
  |  Branch (241:21): [True: 0, False: 0]
  ------------------
  242|      0|                    cur_track->start = time;
  243|      0|                    cur_track->filename = filename;
  244|      0|                } else if (type == 0) {
  ------------------
  |  Branch (244:28): [True: 0, False: 0]
  ------------------
  245|      0|                    cur_track->pregap_start = time;
  246|      0|                }
  247|      0|            }
  248|      0|            break;
  249|     13|        }
  250|     68|        case CUE_FILE:
  ------------------
  |  Branch (250:9): [True: 68, False: 228]
  ------------------
  251|       |            // NOTE: FILE comes before TRACK, so don't use cur_track->filename
  252|     68|            filename = read_quoted(f, &param);
  253|     68|            break;
  254|    296|        }
  255|    296|    }
  256|       |
  257|      6|    return f;
  258|     56|}
cue.c:skip_utf8_bom:
  173|  40.0k|{
  174|  40.0k|    return bstr_startswith0(data, "\xEF\xBB\xBF") ? bstr_cut(data, 3) : data;
  ------------------
  |  Branch (174:12): [True: 12, False: 40.0k]
  ------------------
  175|  40.0k|}
cue.c:read_cmd:
   92|  59.2k|{
   93|  59.2k|    struct bstr line = bstr_strip_linebreaks(bstr_getline(*data, data));
   94|  59.2k|    line = lstrip_whitespace(line);
   95|  59.2k|    if (line.len == 0)
  ------------------
  |  Branch (95:9): [True: 19.1k, False: 40.1k]
  ------------------
   96|  19.1k|        return CUE_EMPTY;
   97|   639k|    for (int n = 0; cue_command_strings[n].command != -1; n++) {
  ------------------
  |  Branch (97:21): [True: 599k, False: 39.9k]
  ------------------
   98|   599k|        struct bstr name = bstr0(cue_command_strings[n].text);
   99|   599k|        if (bstr_case_startswith(line, name)) {
  ------------------
  |  Branch (99:13): [True: 205, False: 598k]
  ------------------
  100|    205|            struct bstr rest = bstr_cut(line, name.len);
  101|    205|            struct bstr par = lstrip_whitespace(rest);
  102|    205|            if (rest.len && par.len == rest.len)
  ------------------
  |  Branch (102:17): [True: 88, False: 117]
  |  Branch (102:29): [True: 17, False: 71]
  ------------------
  103|     17|                continue;
  104|    188|            if (out_params)
  ------------------
  |  Branch (104:17): [True: 82, False: 106]
  ------------------
  105|     82|                *out_params = par;
  106|    188|            return cue_command_strings[n].command;
  107|    205|        }
  108|   599k|    }
  109|  39.9k|    return CUE_ERROR;
  110|  40.1k|}
cue.c:lstrip_whitespace:
   69|  59.5k|{
   70|  65.2k|    while (data.len) {
  ------------------
  |  Branch (70:12): [True: 45.9k, False: 19.3k]
  ------------------
   71|  45.9k|        bstr rest = data;
   72|  45.9k|        int code = bstr_decode_utf8(data, &rest);
   73|  45.9k|        if (code < 0) {
  ------------------
  |  Branch (73:13): [True: 13.9k, False: 31.9k]
  ------------------
   74|       |            // Tolerate Latin1 => probing works (which doesn't convert charsets).
   75|  13.9k|            code = data.start[0];
   76|  13.9k|            rest.start += 1;
   77|  13.9k|            rest.len -= 1;
   78|  13.9k|        }
   79|   337k|        for (size_t n = 0; n < MP_ARRAY_SIZE(spaces); n++) {
  ------------------
  |  |   49|   337k|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (79:28): [True: 297k, False: 40.2k]
  ------------------
   80|   297k|            if (spaces[n] == code) {
  ------------------
  |  Branch (80:17): [True: 5.69k, False: 291k]
  ------------------
   81|  5.69k|                data = rest;
   82|  5.69k|                goto next;
   83|  5.69k|            }
   84|   297k|        }
   85|  40.2k|        break;
   86|  40.2k|    next: ;
   87|  5.69k|    }
   88|  59.5k|    return data;
   89|  59.5k|}
cue.c:strip_quotes:
  136|     13|{
  137|     13|    bstr s = data;
  138|     13|    if (bstr_eatstart0(&s, "\"") && bstr_eatend0(&s, "\""))
  ------------------
  |  Branch (138:9): [True: 2, False: 11]
  |  Branch (138:37): [True: 0, False: 2]
  ------------------
  139|      0|        return s;
  140|     13|    return data;
  141|     13|}
cue.c:eat_char:
  113|     68|{
  114|     68|    if (data->len && data->start[0] == ch) {
  ------------------
  |  Branch (114:9): [True: 26, False: 42]
  |  Branch (114:22): [True: 2, False: 24]
  ------------------
  115|      2|        *data = bstr_cut(*data, 1);
  116|      2|        return true;
  117|     66|    } else {
  118|       |        return false;
  119|     66|    }
  120|     68|}
cue.c:read_quoted:
  123|     68|{
  124|     68|    *data = lstrip_whitespace(*data);
  125|     68|    if (!eat_char(data, '"'))
  ------------------
  |  Branch (125:9): [True: 66, False: 2]
  ------------------
  126|     66|        return NULL;
  127|      2|    int end = bstrchr(*data, '"');
  128|      2|    if (end < 0)
  ------------------
  |  Branch (128:9): [True: 2, False: 0]
  ------------------
  129|      2|        return NULL;
  130|      0|    struct bstr res = bstr_splice(*data, 0, end);
  131|      0|    *data = bstr_cut(*data, end + 1);
  132|      0|    return bstrto0(talloc_ctx, res);
  133|      2|}

demux_set_ts_offset:
  975|  32.5k|{
  976|  32.5k|    struct demux_internal *in = demuxer->in;
  977|  32.5k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  32.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  978|  32.5k|    in->ts_offset = offset;
  979|  32.5k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  32.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  980|  32.5k|}
demux_alloc_sh_stream:
 1004|  80.6k|{
 1005|  80.6k|    struct sh_stream *sh = talloc_ptrtype(NULL, sh);
  ------------------
  |  |   34|  80.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  80.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  80.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1006|  80.6k|    *sh = (struct sh_stream) {
 1007|  80.6k|        .type = type,
 1008|  80.6k|        .index = -1,
 1009|  80.6k|        .ff_index = -1,     // may be overwritten by demuxer
 1010|  80.6k|        .demuxer_id = -1,   // ... same
 1011|  80.6k|        .codec = talloc_zero(sh, struct mp_codec_params),
  ------------------
  |  |   27|  80.6k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  80.6k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  80.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1012|  80.6k|        .tags = talloc_zero(sh, struct mp_tags),
  ------------------
  |  |   27|  80.6k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  80.6k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  80.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|  80.6k|    };
 1014|  80.6k|    sh->codec->type = type;
 1015|  80.6k|    return sh;
 1016|  80.6k|}
demux_add_sh_stream:
 1086|  80.6k|{
 1087|  80.6k|    struct demux_internal *in = demuxer->in;
 1088|  80.6k|    mp_assert(demuxer == in->d_thread);
  ------------------
  |  |   41|  80.6k|#define mp_assert assert
  ------------------
  |  Branch (1088:5): [True: 80.6k, False: 0]
  ------------------
 1089|  80.6k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  80.6k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1090|  80.6k|    demux_add_sh_stream_locked(in, sh);
 1091|  80.6k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  80.6k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1092|  80.6k|}
demux_get_stream:
 1099|   119k|{
 1100|   119k|    struct demux_internal *in = demuxer->in;
 1101|   119k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   119k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1102|   119k|    mp_assert(index >= 0 && index < in->num_streams);
  ------------------
  |  |   41|   119k|#define mp_assert assert
  ------------------
  |  Branch (1102:5): [True: 119k, False: 0]
  |  Branch (1102:5): [True: 119k, False: 0]
  ------------------
 1103|   119k|    struct sh_stream *r = in->streams[index];
 1104|   119k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   119k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1105|   119k|    return r;
 1106|   119k|}
demux_get_num_stream:
 1110|   210k|{
 1111|   210k|    struct demux_internal *in = demuxer->in;
 1112|   210k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   210k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1113|   210k|    int r = in->num_streams;
 1114|   210k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   210k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1115|   210k|    return r;
 1116|   210k|}
demux_free:
 1159|   415k|{
 1160|   415k|    if (!demuxer)
  ------------------
  |  Branch (1160:9): [True: 40.0k, False: 375k]
  ------------------
 1161|  40.0k|        return;
 1162|   375k|    struct demux_internal *in = demuxer->in;
 1163|   375k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   375k|#define mp_assert assert
  ------------------
  |  Branch (1163:5): [True: 375k, False: 0]
  ------------------
 1164|       |
 1165|   375k|    demux_stop_thread(demuxer);
 1166|   375k|    demux_shutdown(in);
 1167|   375k|    demux_dealloc(in);
 1168|   375k|}
demux_free_async:
 1178|  39.1k|{
 1179|  39.1k|    struct demux_internal *in = demuxer->in;
 1180|  39.1k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  39.1k|#define mp_assert assert
  ------------------
  |  Branch (1180:5): [True: 39.1k, False: 0]
  ------------------
 1181|       |
 1182|  39.1k|    if (!in->threading)
  ------------------
  |  Branch (1182:9): [True: 2.34k, False: 36.8k]
  ------------------
 1183|  2.34k|        return NULL;
 1184|       |
 1185|  36.8k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  36.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1186|  36.8k|    in->thread_terminate = true;
 1187|  36.8k|    in->shutdown_async = true;
 1188|  36.8k|    mp_cond_signal(&in->wakeup);
 1189|  36.8k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  36.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1190|       |
 1191|  36.8k|    return (struct demux_free_async_state *)demuxer->in; // lies
 1192|  39.1k|}
demux_free_async_finish:
 1210|   118k|{
 1211|   118k|    struct demux_internal *in = (struct demux_internal *)state; // reverse lies
 1212|       |
 1213|   118k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   118k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1214|   118k|    bool busy = in->shutdown_async;
 1215|   118k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   118k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1216|       |
 1217|   118k|    if (busy)
  ------------------
  |  Branch (1217:9): [True: 81.9k, False: 36.8k]
  ------------------
 1218|  81.9k|        return false;
 1219|       |
 1220|  36.8k|    demux_stop_thread(in->d_user);
 1221|  36.8k|    demux_dealloc(in);
 1222|       |    return true;
 1223|   118k|}
demux_cancel_and_free:
 1229|  65.0k|{
 1230|  65.0k|    if (!demuxer)
  ------------------
  |  Branch (1230:9): [True: 44.3k, False: 20.6k]
  ------------------
 1231|  44.3k|        return;
 1232|  20.6k|    mp_cancel_trigger(demuxer->cancel);
 1233|  20.6k|    demux_free(demuxer);
 1234|  20.6k|}
demux_start_thread:
 1238|  55.1k|{
 1239|  55.1k|    struct demux_internal *in = demuxer->in;
 1240|  55.1k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  55.1k|#define mp_assert assert
  ------------------
  |  Branch (1240:5): [True: 55.1k, False: 0]
  ------------------
 1241|       |
 1242|  55.1k|    if (!in->threading) {
  ------------------
  |  Branch (1242:9): [True: 55.1k, False: 0]
  ------------------
 1243|  55.1k|        in->threading = true;
 1244|  55.1k|        if (mp_thread_create(&in->thread, demux_thread, in))
  ------------------
  |  |  214|  55.1k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 55.1k]
  |  |  ------------------
  ------------------
 1245|      0|            in->threading = false;
 1246|  55.1k|    }
 1247|  55.1k|}
demux_stop_thread:
 1250|   412k|{
 1251|   412k|    struct demux_internal *in = demuxer->in;
 1252|   412k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   412k|#define mp_assert assert
  ------------------
  |  Branch (1252:5): [True: 412k, False: 0]
  ------------------
 1253|       |
 1254|   412k|    if (in->threading) {
  ------------------
  |  Branch (1254:9): [True: 55.1k, False: 356k]
  ------------------
 1255|  55.1k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  55.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1256|  55.1k|        in->thread_terminate = true;
 1257|  55.1k|        mp_cond_signal(&in->wakeup);
 1258|  55.1k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  55.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1259|  55.1k|        mp_thread_join(in->thread);
  ------------------
  |  |  215|  55.1k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1260|  55.1k|        in->threading = false;
 1261|       |        in->thread_terminate = false;
 1262|  55.1k|    }
 1263|   412k|}
demux_set_wakeup_cb:
 1267|  94.3k|{
 1268|  94.3k|    struct demux_internal *in = demuxer->in;
 1269|  94.3k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  94.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1270|  94.3k|    in->wakeup_cb = cb;
 1271|  94.3k|    in->wakeup_cb_ctx = ctx;
 1272|  94.3k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  94.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1273|  94.3k|}
stream_type_name:
 1314|   900k|{
 1315|   900k|    switch (type) {
 1316|   812k|    case STREAM_VIDEO:  return "video";
  ------------------
  |  Branch (1316:5): [True: 812k, False: 88.0k]
  ------------------
 1317|      0|    case STREAM_AUDIO:  return "audio";
  ------------------
  |  Branch (1317:5): [True: 0, False: 900k]
  ------------------
 1318|  88.0k|    case STREAM_SUB:    return "sub";
  ------------------
  |  Branch (1318:5): [True: 88.0k, False: 812k]
  ------------------
 1319|      0|    default:            return "unknown";
  ------------------
  |  Branch (1319:5): [True: 0, False: 900k]
  ------------------
 1320|   900k|    }
 1321|   900k|}
demux_append_codec_desc:
 1333|  39.5k|{
 1334|  39.5k|    struct mp_codec_params *c = sh->codec;
 1335|       |
 1336|  39.5k|    bstr_xappend0(ta_ctx, dst, c->codec ? c->codec : "<unknown>");
  ------------------
  |  Branch (1336:32): [True: 39.5k, False: 0]
  ------------------
 1337|       |
 1338|  39.5k|    if (c->codec_profile)
  ------------------
  |  Branch (1338:9): [True: 22, False: 39.5k]
  ------------------
 1339|     22|        bstr_xappend_asprintf(ta_ctx, dst, " [%s]", c->codec_profile);
 1340|  39.5k|    if (c->disp_w)
  ------------------
  |  Branch (1340:9): [True: 32.5k, False: 6.98k]
  ------------------
 1341|  32.5k|        append_field(ta_ctx, dst, skip_dup,
 1342|  32.5k|                     mp_tprintf(32, "%dx%d", c->disp_w, c->disp_h));
  ------------------
  |  |  195|  32.5k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1343|  39.5k|    if (c->fps && !sh->image) {
  ------------------
  |  Branch (1343:9): [True: 32.5k, False: 6.97k]
  |  Branch (1343:19): [True: 32.5k, False: 0]
  ------------------
 1344|  32.5k|        char *fps = mp_format_double(ta_ctx, c->fps, 4, false, false, true);
 1345|  32.5k|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%s fps", fps));
  ------------------
  |  |  195|  32.5k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1346|  32.5k|    }
 1347|  39.5k|    if (c->channels.num)
  ------------------
  |  Branch (1347:9): [True: 123, False: 39.4k]
  ------------------
 1348|    123|        bstr_xappend_asprintf(ta_ctx, dst, " %dch", c->channels.num);
 1349|  39.5k|    if (c->samplerate)
  ------------------
  |  Branch (1349:9): [True: 91, False: 39.4k]
  ------------------
 1350|     91|        bstr_xappend_asprintf(ta_ctx, dst, " %d Hz", c->samplerate);
 1351|  39.5k|    int bitrate = 0;
 1352|  39.5k|    if (c->bitrate > 0 && c->bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1352:9): [True: 100, False: 39.4k]
  |  Branch (1352:27): [True: 100, False: 0]
  ------------------
 1353|    100|        bitrate = (c->bitrate + 500) / 1000;
 1354|  39.4k|    } else if (sh->hls_bitrate > 0 && sh->hls_bitrate < INT_MAX - 500) {
  ------------------
  |  Branch (1354:16): [True: 0, False: 39.4k]
  |  Branch (1354:39): [True: 0, False: 0]
  ------------------
 1355|      0|        bitrate = (sh->hls_bitrate + 500) / 1000;
 1356|      0|    }
 1357|  39.5k|    if (bitrate)
  ------------------
  |  Branch (1357:9): [True: 100, False: 39.4k]
  ------------------
 1358|    100|        append_field(ta_ctx, dst, skip_dup, mp_tprintf(32, "%d kbps", bitrate));
  ------------------
  |  |  195|    100|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1359|  39.5k|}
demux_read_packet_async:
 2974|   890k|{
 2975|   890k|    return demux_read_packet_async_until(sh, MP_NOPTS_VALUE, out_pkt);
  ------------------
  |  |   39|   890k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2976|   890k|}
demux_read_packet_async_until:
 2984|  1.45M|{
 2985|  1.45M|    struct demux_stream *ds = sh ? sh->ds : NULL;
  ------------------
  |  Branch (2985:31): [True: 1.45M, False: 0]
  ------------------
 2986|  1.45M|    *out_pkt = NULL;
 2987|  1.45M|    if (!ds)
  ------------------
  |  Branch (2987:9): [True: 0, False: 1.45M]
  ------------------
 2988|      0|        return -1;
 2989|  1.45M|    struct demux_internal *in = ds->in;
 2990|       |
 2991|  1.45M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.45M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2992|  1.45M|    int r = -1;
 2993|  1.46M|    while (1) {
  ------------------
  |  Branch (2993:12): [True: 1.46M, Folded]
  ------------------
 2994|  1.46M|        r = dequeue_packet(ds, min_pts, out_pkt);
 2995|  1.46M|        if (in->threading || in->blocked || r != 0)
  ------------------
  |  Branch (2995:13): [True: 1.26M, False: 204k]
  |  Branch (2995:30): [True: 0, False: 204k]
  |  Branch (2995:45): [True: 191k, False: 12.4k]
  ------------------
 2996|  1.45M|            break;
 2997|       |        // Needs to actually read packets until we got a packet or EOF.
 2998|  12.4k|        thread_work(in);
 2999|  12.4k|    }
 3000|  1.45M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.45M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3001|  1.45M|    return r;
 3002|  1.45M|}
demux_update:
 3400|   999k|{
 3401|   999k|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|   999k|#define mp_assert assert
  ------------------
  |  Branch (3401:5): [True: 999k, False: 0]
  ------------------
 3402|   999k|    struct demux_internal *in = demuxer->in;
 3403|       |
 3404|   999k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   999k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3405|       |
 3406|   999k|    if (!in->threading)
  ------------------
  |  Branch (3406:9): [True: 57.5k, False: 941k]
  ------------------
 3407|  57.5k|        update_cache(in);
 3408|       |
 3409|       |    // This implies this function is actually called from "the" user thread.
 3410|   999k|    in->d_user->filesize = in->stream_size;
 3411|       |
 3412|   999k|    pts = MP_ADD_PTS(pts, -in->ts_offset);
  ------------------
  |  |   67|   999k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   999k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 57.5k, False: 941k]
  |  |  ------------------
  ------------------
 3413|       |
 3414|   999k|    struct timed_metadata *prev = lookup_timed_metadata(in, in->last_playback_pts);
 3415|   999k|    struct timed_metadata *cur = lookup_timed_metadata(in, pts);
 3416|   999k|    if (prev != cur || in->force_metadata_update) {
  ------------------
  |  Branch (3416:9): [True: 0, False: 999k]
  |  Branch (3416:24): [True: 57.5k, False: 941k]
  ------------------
 3417|  57.5k|        in->force_metadata_update = false;
 3418|  57.5k|        update_final_metadata(demuxer, cur);
 3419|  57.5k|        demuxer->events |= DEMUX_EVENT_METADATA;
 3420|  57.5k|    }
 3421|       |
 3422|   999k|    in->last_playback_pts = pts;
 3423|       |
 3424|   999k|    demuxer->events |= in->events;
 3425|   999k|    in->events = 0;
 3426|   999k|    if (in->lists_changed) {
  ------------------
  |  Branch (3426:9): [True: 0, False: 999k]
  ------------------
 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|  2.02M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3434:21): [True: 1.02M, False: 999k]
  ------------------
 3435|  1.02M|        struct demux_stream *ds = in->streams[n]->ds;
 3436|  1.02M|        if (ds->staged_codec) {
  ------------------
  |  Branch (3436:13): [True: 0, False: 1.02M]
  ------------------
 3437|      0|            in->streams[n]->codec = ds->staged_codec;
 3438|      0|            ds->staged_codec = NULL;
 3439|      0|        }
 3440|  1.02M|    }
 3441|   999k|    if (demuxer->events & (DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS | DEMUX_EVENT_CODEC))
  ------------------
  |  Branch (3441:9): [True: 90.0k, False: 909k]
  ------------------
 3442|  90.0k|        demux_update_replaygain(demuxer);
 3443|   999k|    if (demuxer->events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (3443:9): [True: 150k, False: 848k]
  ------------------
 3444|   150k|        demuxer->duration = in->duration;
 3445|       |
 3446|   999k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   999k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3447|   999k|}
demux_close_stream:
 3484|  2.35k|{
 3485|  2.35k|    struct demux_internal *in = demuxer->in;
 3486|  2.35k|    mp_assert(!in->threading && demuxer == in->d_thread);
  ------------------
  |  |   41|  2.35k|#define mp_assert assert
  ------------------
  |  Branch (3486:5): [True: 2.35k, False: 0]
  |  Branch (3486:5): [True: 2.35k, False: 0]
  ------------------
 3487|       |
 3488|  2.35k|    if (!demuxer->stream || !in->owns_stream)
  ------------------
  |  Branch (3488:9): [True: 0, False: 2.35k]
  |  Branch (3488:29): [True: 0, False: 2.35k]
  ------------------
 3489|      0|        return;
 3490|       |
 3491|  2.35k|    MP_VERBOSE(demuxer, "demuxer read all data; closing stream\n");
  ------------------
  |  |   92|  2.35k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.35k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3492|  2.35k|    free_stream(demuxer->stream);
 3493|  2.35k|    demuxer->stream = NULL;
 3494|       |    in->d_user->stream = NULL;
 3495|  2.35k|}
demux_open_url:
 3766|  65.0k|{
 3767|  65.0k|    if (!params)
  ------------------
  |  Branch (3767:9): [True: 0, False: 65.0k]
  ------------------
 3768|      0|        return NULL;
 3769|  65.0k|    struct mp_cancel *priv_cancel = mp_cancel_new(NULL);
 3770|  65.0k|    if (cancel)
  ------------------
  |  Branch (3770:9): [True: 65.0k, False: 0]
  ------------------
 3771|  65.0k|        mp_cancel_set_parent(priv_cancel, cancel);
 3772|  65.0k|    struct stream *s = params->external_stream;
 3773|  65.0k|    if (!s) {
  ------------------
  |  Branch (3773:9): [True: 65.0k, False: 0]
  ------------------
 3774|  65.0k|        s = stream_create(url, STREAM_READ | params->stream_flags,
  ------------------
  |  |   41|  65.0k|#define STREAM_READ               0
  ------------------
 3775|  65.0k|                          priv_cancel, global);
 3776|  65.0k|        if (s && params->init_fragment.len) {
  ------------------
  |  Branch (3776:13): [True: 65.0k, False: 0]
  |  Branch (3776:18): [True: 0, False: 65.0k]
  ------------------
 3777|      0|            s = create_webshit_concat_stream(global, priv_cancel,
 3778|      0|                                             params->init_fragment, s);
 3779|      0|        }
 3780|  65.0k|    }
 3781|  65.0k|    if (!s) {
  ------------------
  |  Branch (3781:9): [True: 0, False: 65.0k]
  ------------------
 3782|      0|        talloc_free(priv_cancel);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3783|      0|        return NULL;
 3784|      0|    }
 3785|  65.0k|    struct demuxer *d = demux_open(s, priv_cancel, params, global);
 3786|  65.0k|    if (d) {
  ------------------
  |  Branch (3786:9): [True: 57.5k, False: 7.50k]
  ------------------
 3787|  57.5k|        talloc_steal(d->in, priv_cancel);
  ------------------
  |  |   38|  57.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  57.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3788|  57.5k|        mp_assert(d->cancel);
  ------------------
  |  |   41|  57.5k|#define mp_assert assert
  ------------------
  |  Branch (3788:9): [True: 57.5k, False: 0]
  ------------------
 3789|  57.5k|    } else {
 3790|  7.50k|        params->demuxer_failed = true;
 3791|  7.50k|        if (!params->external_stream)
  ------------------
  |  Branch (3791:13): [True: 7.50k, False: 0]
  ------------------
 3792|  7.50k|            free_stream(s);
 3793|  7.50k|        talloc_free(priv_cancel);
  ------------------
  |  |   47|  7.50k|#define talloc_free                     ta_free
  ------------------
 3794|  7.50k|    }
 3795|  65.0k|    return d;
 3796|  65.0k|}
demux_flush:
 3800|   412k|{
 3801|   412k|    struct demux_internal *in = demuxer->in;
 3802|   412k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|   412k|#define mp_assert assert
  ------------------
  |  Branch (3802:5): [True: 412k, False: 0]
  ------------------
 3803|       |
 3804|   412k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   412k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3805|   412k|    clear_reader_state(in, true);
 3806|   469k|    for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (3806:21): [True: 57.5k, False: 412k]
  ------------------
 3807|  57.5k|        clear_cached_range(in, in->ranges[n]);
 3808|   412k|    free_empty_cached_ranges(in);
 3809|   492k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3809:21): [True: 80.6k, False: 412k]
  ------------------
 3810|  80.6k|        struct demux_stream *ds = in->streams[n]->ds;
 3811|  80.6k|        ds->refreshing = false;
 3812|  80.6k|        ds->eof = false;
 3813|  80.6k|    }
 3814|   412k|    in->eof = false;
 3815|   412k|    in->seeking = false;
 3816|   412k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   412k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3817|   412k|}
demux_seek:
 4076|  2.34k|{
 4077|  2.34k|    struct demux_internal *in = demuxer->in;
 4078|  2.34k|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  2.34k|#define mp_assert assert
  ------------------
  |  Branch (4078:5): [True: 2.34k, False: 0]
  ------------------
 4079|       |
 4080|  2.34k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  2.34k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4081|       |
 4082|  2.34k|    if (!(flags & SEEK_FACTOR))
  ------------------
  |  |   94|  2.34k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (4082:9): [True: 2.34k, False: 0]
  ------------------
 4083|  2.34k|        seek_pts = MP_ADD_PTS(seek_pts, -in->ts_offset);
  ------------------
  |  |   67|  2.34k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  2.34k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 2.34k]
  |  |  ------------------
  ------------------
 4084|       |
 4085|  2.34k|    int res = queue_seek(in, seek_pts, flags, true);
 4086|       |
 4087|  2.34k|    mp_cond_signal(&in->wakeup);
 4088|  2.34k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  2.34k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4089|       |
 4090|  2.34k|    return res;
 4091|  2.34k|}
demuxer_select_track:
 4325|  39.5k|{
 4326|  39.5k|    struct demux_internal *in = demuxer->in;
 4327|  39.5k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  39.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4328|  39.5k|    bool changed = select_track(in, stream, ref_pts, selected);
 4329|  39.5k|    changed |= select_dependent_tracks(in, stream, ref_pts, selected);
 4330|  39.5k|    if (changed) {
  ------------------
  |  Branch (4330:9): [True: 39.2k, False: 340]
  ------------------
 4331|  39.2k|        if (in->threading) {
  ------------------
  |  Branch (4331:13): [True: 36.8k, False: 2.34k]
  ------------------
 4332|  36.8k|            mp_cond_signal(&in->wakeup);
 4333|  36.8k|        } else {
 4334|  2.34k|            execute_trackswitch(in);
 4335|  2.34k|        }
 4336|  39.2k|    }
 4337|  39.5k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  39.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4338|  39.5k|}
demux_stream_is_selected:
 4390|   996k|{
 4391|   996k|    if (!stream)
  ------------------
  |  Branch (4391:9): [True: 0, False: 996k]
  ------------------
 4392|      0|        return false;
 4393|   996k|    bool r = false;
 4394|   996k|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|   996k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4395|   996k|    r = stream->ds->selected;
 4396|   996k|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|   996k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4397|   996k|    return r;
 4398|   996k|}
demux_stream_eof_is_lazy:
 4405|   909k|{
 4406|   909k|    if (!stream)
  ------------------
  |  Branch (4406:9): [True: 0, False: 909k]
  ------------------
 4407|      0|        return false;
 4408|   909k|    mp_mutex_lock(&stream->ds->in->lock);
  ------------------
  |  |  134|   909k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4409|   909k|    bool r = stream->ds->lazy_eof;
 4410|   909k|    mp_mutex_unlock(&stream->ds->in->lock);
  ------------------
  |  |  136|   909k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4411|   909k|    return r;
 4412|   909k|}
demux_set_stream_wakeup_cb:
 4427|  76.4k|{
 4428|  76.4k|    mp_mutex_lock(&sh->ds->in->lock);
  ------------------
  |  |  134|  76.4k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4429|  76.4k|    sh->ds->wakeup_cb = cb;
 4430|  76.4k|    sh->ds->wakeup_cb_ctx = ctx;
 4431|  76.4k|    sh->ds->need_wakeup = true;
 4432|  76.4k|    mp_mutex_unlock(&sh->ds->in->lock);
  ------------------
  |  |  136|  76.4k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4433|  76.4k|}
demux_get_reader_state:
 4874|  1.75M|{
 4875|  1.75M|    struct demux_internal *in = demuxer->in;
 4876|  1.75M|    mp_assert(demuxer == in->d_user);
  ------------------
  |  |   41|  1.75M|#define mp_assert assert
  ------------------
  |  Branch (4876:5): [True: 1.75M, False: 0]
  ------------------
 4877|       |
 4878|  1.75M|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  1.75M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4879|       |
 4880|  1.75M|    *r = (struct demux_reader_state){
 4881|  1.75M|        .eof = in->eof,
 4882|  1.75M|        .ts_info = {
 4883|  1.75M|            .reader = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4884|  1.75M|            .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4885|  1.75M|            .duration = -1,
 4886|  1.75M|        },
 4887|  1.75M|        .total_bytes = in->total_bytes,
 4888|  1.75M|        .seeking = in->seeking_in_progress,
 4889|  1.75M|        .low_level_seeks = in->low_level_seeks,
 4890|  1.75M|        .ts_last = in->demux_ts,
 4891|  1.75M|        .bytes_per_second = in->bytes_per_second,
 4892|  1.75M|        .byte_level_seeks = in->byte_level_seeks,
 4893|  1.75M|        .file_cache_bytes = in->cache ? demux_cache_get_size(in->cache) : -1,
  ------------------
  |  Branch (4893:29): [True: 0, False: 1.75M]
  ------------------
 4894|  1.75M|    };
 4895|  1.75M|    bool any_packets = false;
 4896|  7.02M|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4896:21): [True: 5.27M, False: 1.75M]
  ------------------
 4897|  5.27M|        r->ts_per_stream[n] = r->ts_info;
 4898|  5.27M|    }
 4899|  3.51M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4899:21): [True: 1.75M, False: 1.75M]
  ------------------
 4900|  1.75M|        struct demux_stream *ds = in->streams[n]->ds;
 4901|  1.75M|        if (ds->eager && !(!ds->queue->head && ds->eof) && !ds->ignore_eof) {
  ------------------
  |  Branch (4901:13): [True: 1.72M, False: 32.5k]
  |  Branch (4901:28): [True: 127k, False: 1.59M]
  |  Branch (4901:48): [True: 97.9k, False: 29.7k]
  |  Branch (4901:60): [True: 1.62M, False: 0]
  ------------------
 4902|  1.62M|            r->underrun |= !ds->reader_head && !ds->eof && !ds->still_image;
  ------------------
  |  Branch (4902:28): [True: 29.7k, False: 1.59M]
  |  Branch (4902:48): [True: 29.7k, False: 0]
  |  Branch (4902:60): [True: 29.7k, False: 0]
  ------------------
 4903|  1.62M|            any_packets |= !!ds->reader_head;
 4904|       |
 4905|  1.62M|            double ts_reader = ds->base_ts;
 4906|  1.62M|            double ts_end = ds->queue->last_ts;
 4907|  1.62M|            double ts_duration = -1;
 4908|  1.62M|            if (ts_reader != MP_NOPTS_VALUE && ts_reader <= ts_end)
  ------------------
  |  |   39|  3.25M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4908:17): [True: 1.59M, False: 29.7k]
  |  Branch (4908:48): [True: 1.59M, False: 0]
  ------------------
 4909|  1.59M|                ts_duration = ts_end - ts_reader;
 4910|       |
 4911|  1.62M|            struct demux_ctrl_ts_info *i = &r->ts_per_stream[ds->type];
 4912|  1.62M|            i->reader = MP_PTS_MIN(i->reader, ts_reader);
  ------------------
  |  |   64|  1.62M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  3.25M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 1.62M]
  |  |  |  |  |  Branch (45:23): [True: 1.62M, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 29.7k, False: 1.59M]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 1.62M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4913|  1.62M|            i->end = MP_PTS_MIN(i->end, ts_end);
  ------------------
  |  |   64|  1.62M|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  3.25M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 1.62M]
  |  |  |  |  |  Branch (45:23): [True: 1.62M, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 29.7k, False: 1.59M]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 1.62M, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4914|  1.62M|            i->duration = ts_duration;
 4915|  1.62M|        }
 4916|  1.75M|        r->fw_bytes += get_forward_buffered_bytes(ds);
 4917|  1.75M|    }
 4918|  1.75M|    struct demux_ctrl_ts_info *ots = &r->ts_info;
 4919|       |    // find stream type with lowest duration and use its state
 4920|  7.02M|    for (int n = 0; n < STREAM_TYPE_COUNT; n++) {
  ------------------
  |  Branch (4920:21): [True: 5.27M, False: 1.75M]
  ------------------
 4921|  5.27M|        struct demux_ctrl_ts_info *ts = &r->ts_per_stream[n];
 4922|  5.27M|        if (r->ts_info.duration != -1) {
  ------------------
  |  Branch (4922:13): [True: 3.19M, False: 2.07M]
  ------------------
 4923|       |            // skip if timestamps unknown
 4924|  3.19M|            if (ts->duration == -1)
  ------------------
  |  Branch (4924:17): [True: 3.19M, False: 0]
  ------------------
 4925|  3.19M|                continue;
 4926|       |            // skip if we already know of a smaller cached stream
 4927|      0|            if (ts->duration > ots->duration)
  ------------------
  |  Branch (4927:17): [True: 0, False: 0]
  ------------------
 4928|      0|                continue;
 4929|       |            // skip empty subtitle streams when other streams exist
 4930|      0|            if (n == STREAM_SUB && ts->duration == 0.0)
  ------------------
  |  Branch (4930:17): [True: 0, False: 0]
  |  Branch (4930:36): [True: 0, False: 0]
  ------------------
 4931|      0|                continue;
 4932|      0|        }
 4933|  2.07M|        ots->duration = ts->duration;
 4934|  2.07M|        ots->reader = ts->reader;
 4935|  2.07M|        ots->end = ts->end;
 4936|  2.07M|    }
 4937|  1.75M|    r->idle = (!in->reading && !r->underrun) || r->eof;
  ------------------
  |  Branch (4937:16): [True: 1.70M, False: 57.0k]
  |  Branch (4937:32): [True: 1.70M, False: 0]
  |  Branch (4937:49): [True: 0, False: 57.0k]
  ------------------
 4938|  1.75M|    r->underrun &= !r->idle && in->threading;
  ------------------
  |  Branch (4938:20): [True: 57.0k, False: 1.70M]
  |  Branch (4938:32): [True: 57.0k, False: 0]
  ------------------
 4939|  1.75M|    ots->reader = MP_ADD_PTS(ots->reader, in->ts_offset);
  ------------------
  |  |   67|  1.75M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 160k, False: 1.59M]
  |  |  ------------------
  ------------------
 4940|  1.75M|    ots->end = MP_ADD_PTS(ots->end, in->ts_offset);
  ------------------
  |  |   67|  1.75M|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 160k, False: 1.59M]
  |  |  ------------------
  ------------------
 4941|  1.75M|    if (ots->reader != MP_NOPTS_VALUE && ots->reader <= ots->end)
  ------------------
  |  |   39|  3.51M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4941:9): [True: 1.59M, False: 160k]
  |  Branch (4941:42): [True: 1.59M, False: 0]
  ------------------
 4942|  1.59M|        ots->duration = ots->end - ots->reader;
 4943|  1.75M|    if (in->seeking || !any_packets)
  ------------------
  |  Branch (4943:9): [True: 0, False: 1.75M]
  |  Branch (4943:24): [True: 160k, False: 1.59M]
  ------------------
 4944|   160k|        ots->duration = 0;
 4945|  3.51M|    for (int n = 0; n < MPMIN(in->num_ranges, MAX_SEEK_RANGES); n++) {
  ------------------
  |  |   45|  3.51M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 3.51M]
  |  |  ------------------
  ------------------
  |  Branch (4945:21): [True: 1.75M, False: 1.75M]
  ------------------
 4946|  1.75M|        struct demux_cached_range *range = in->ranges[n];
 4947|  1.75M|        if (range->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4947:13): [True: 0, False: 1.75M]
  ------------------
 4948|      0|            r->seek_ranges[r->num_seek_ranges++] =
 4949|      0|                (struct demux_seek_range){
 4950|      0|                    .start = MP_ADD_PTS(range->seek_start, in->ts_offset),
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4951|      0|                    .end = MP_ADD_PTS(range->seek_end, in->ts_offset),
  ------------------
  |  |   67|      0|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 4952|      0|                };
 4953|      0|            r->bof_cached |= range->is_bof;
 4954|      0|            r->eof_cached |= range->is_eof;
 4955|      0|        }
 4956|  1.75M|    }
 4957|       |
 4958|  1.75M|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  1.75M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4959|  1.75M|}
demux_cancel_test:
 4962|  3.15M|{
 4963|  3.15M|    return mp_cancel_test(demuxer->cancel);
 4964|  3.15M|}
demux_read_interrupted:
 4969|  1.29M|{
 4970|  1.29M|    struct demux_internal *in = demuxer->in;
 4971|  1.29M|    return atomic_load_explicit(&in->seeking, memory_order_relaxed) ||
  ------------------
  |  Branch (4971:12): [True: 0, False: 1.29M]
  ------------------
 4972|  1.29M|           atomic_load_explicit(&in->thread_terminate, memory_order_relaxed) ||
  ------------------
  |  Branch (4972:12): [True: 0, False: 1.29M]
  ------------------
 4973|  1.29M|           demux_cancel_test(demuxer);
  ------------------
  |  Branch (4973:12): [True: 18.4E, False: 1.29M]
  ------------------
 4974|  1.29M|}
demux_copy_chapter_data:
 4977|  32.5k|{
 4978|  32.5k|    struct demux_chapter *new = talloc_array(NULL, struct demux_chapter, num);
  ------------------
  |  |   29|  32.5k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  32.5k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4979|  32.5k|    for (int n = 0; n < num; n++) {
  ------------------
  |  Branch (4979:21): [True: 0, False: 32.5k]
  ------------------
 4980|      0|        new[n] = c[n];
 4981|      0|        new[n].metadata = mp_tags_dup(new, new[n].metadata);
 4982|      0|    }
 4983|  32.5k|    return new;
 4984|  32.5k|}
demux.c:update_stream_eager_state:
  900|   119k|{
  901|   119k|    bool any_av_streams = false;
  902|   119k|    bool any_streams = false;
  903|       |
  904|  1.96M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (904:21): [True: 1.84M, False: 119k]
  ------------------
  905|  1.84M|        struct demux_stream *s = in->streams[n]->ds;
  906|       |
  907|  1.84M|        s->still_image = s->sh->still_image;
  908|  1.84M|        s->eager = s->selected && !s->sh->absent && !s->sh->attached_picture;
  ------------------
  |  Branch (908:20): [True: 39.2k, False: 1.81M]
  |  Branch (908:35): [True: 39.2k, False: 0]
  |  Branch (908:53): [True: 39.2k, False: 0]
  ------------------
  909|  1.84M|        if (s->eager && !s->still_image)
  ------------------
  |  Branch (909:13): [True: 39.2k, False: 1.81M]
  |  Branch (909:25): [True: 39.2k, False: 0]
  ------------------
  910|  39.2k|            any_av_streams |= s->type != STREAM_SUB;
  911|  1.84M|        any_streams |= s->selected;
  912|  1.84M|    }
  913|       |
  914|       |    // Subtitles and sparse still-image video are only eagerly read if there are
  915|       |    // no other eagerly read streams.
  916|   119k|    if (any_av_streams) {
  ------------------
  |  Branch (916:9): [True: 32.5k, False: 87.3k]
  ------------------
  917|  65.0k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (917:25): [True: 32.5k, False: 32.5k]
  ------------------
  918|  32.5k|            struct demux_stream *s = in->streams[n]->ds;
  919|       |
  920|  32.5k|            if (s->type == STREAM_SUB || s->still_image)
  ------------------
  |  Branch (920:17): [True: 0, False: 32.5k]
  |  Branch (920:42): [True: 0, False: 32.5k]
  ------------------
  921|      0|                s->eager = false;
  922|  32.5k|        }
  923|  32.5k|    }
  924|       |
  925|   119k|    if (!any_streams)
  ------------------
  |  Branch (925:9): [True: 80.6k, False: 39.2k]
  ------------------
  926|  80.6k|        in->blocked = false;
  927|   119k|}
demux.c:demux_add_sh_stream_locked:
 1023|  80.6k|{
 1024|  80.6k|    mp_assert(!sh->ds); // must not be added yet
  ------------------
  |  |   41|  80.6k|#define mp_assert assert
  ------------------
  |  Branch (1024:5): [True: 80.6k, False: 0]
  ------------------
 1025|       |
 1026|  80.6k|    sh->index = in->num_streams;
 1027|       |
 1028|  80.6k|    sh->ds = talloc(sh, struct demux_stream);
  ------------------
  |  |   26|  80.6k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  80.6k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  80.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1029|  80.6k|    *sh->ds = (struct demux_stream) {
 1030|  80.6k|        .in = in,
 1031|  80.6k|        .sh = sh,
 1032|  80.6k|        .type = sh->type,
 1033|  80.6k|        .index = sh->index,
 1034|  80.6k|        .global_correct_dts = true,
 1035|  80.6k|        .global_correct_pos = true,
 1036|  80.6k|    };
 1037|       |
 1038|  80.6k|    struct demux_stream *ds = sh->ds;
 1039|       |
 1040|  80.6k|    if (!sh->codec->codec)
  ------------------
  |  Branch (1040:9): [True: 23.2k, False: 57.4k]
  ------------------
 1041|  23.2k|        sh->codec->codec = "";
 1042|       |
 1043|  80.6k|    MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh);
  ------------------
  |  |  105|  80.6k|    do {                                            \
  |  |  106|  80.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  80.6k|    do {                                            \
  |  |  |  |   97|  80.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  80.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  80.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  80.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 58.5k, False: 22.1k]
  |  |  |  |  ------------------
  |  |  |  |   99|  80.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  58.5k|    do {                                                        \
  |  |  |  |  |  |   89|  58.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  58.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  58.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  58.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  58.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  58.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  58.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 58.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  80.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 80.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  80.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  80.6k|        (idxvar)++;                                 \
  |  |  109|  80.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 80.6k]
  |  |  ------------------
  ------------------
 1044|  80.6k|    mp_assert(in->streams[sh->index] == sh);
  ------------------
  |  |   41|  80.6k|#define mp_assert assert
  ------------------
  |  Branch (1044:5): [True: 80.6k, False: 0]
  ------------------
 1045|       |
 1046|  80.6k|    if (in->current_range) {
  ------------------
  |  Branch (1046:9): [True: 65, False: 80.6k]
  ------------------
 1047|    130|        for (int n = 0; n < in->num_ranges; n++)
  ------------------
  |  Branch (1047:25): [True: 65, False: 65]
  ------------------
 1048|     65|            add_missing_streams(in, in->ranges[n]);
 1049|       |
 1050|     65|        sh->ds->queue = in->current_range->streams[sh->ds->index];
 1051|     65|    }
 1052|       |
 1053|  80.6k|    update_stream_selection_state(in, sh->ds);
 1054|       |
 1055|  80.6k|    switch (ds->type) {
  ------------------
  |  Branch (1055:13): [True: 73.9k, False: 6.69k]
  ------------------
 1056|  28.3k|    case STREAM_AUDIO:
  ------------------
  |  Branch (1056:5): [True: 28.3k, False: 52.2k]
  ------------------
 1057|  28.3k|        ds->back_preroll = in->d_user->opts->audio_back_preroll;
 1058|  28.3k|        if (ds->back_preroll < 0) { // auto
  ------------------
  |  Branch (1058:13): [True: 28.3k, False: 0]
  ------------------
 1059|  28.3k|            ds->back_preroll = mp_codec_is_lossless(sh->codec->codec) ? 0 : 1;
  ------------------
  |  Branch (1059:32): [True: 771, False: 27.6k]
  ------------------
 1060|  28.3k|            if (sh->codec->codec && (strcmp(sh->codec->codec, "opus") == 0 ||
  ------------------
  |  Branch (1060:17): [True: 28.3k, False: 0]
  |  Branch (1060:38): [True: 0, False: 28.3k]
  ------------------
 1061|  28.3k|                                     strcmp(sh->codec->codec, "vorbis") == 0 ||
  ------------------
  |  Branch (1061:38): [True: 0, False: 28.3k]
  ------------------
 1062|  28.3k|                                     strcmp(sh->codec->codec, "mp3") == 0))
  ------------------
  |  Branch (1062:38): [True: 1.11k, False: 27.2k]
  ------------------
 1063|  1.11k|                ds->back_preroll = 2;
 1064|  28.3k|        }
 1065|  28.3k|        break;
 1066|  45.5k|    case STREAM_VIDEO:
  ------------------
  |  Branch (1066:5): [True: 45.5k, False: 35.0k]
  ------------------
 1067|  45.5k|        ds->back_preroll = in->d_user->opts->video_back_preroll;
 1068|  45.5k|        if (ds->back_preroll < 0)
  ------------------
  |  Branch (1068:13): [True: 45.5k, False: 0]
  ------------------
 1069|  45.5k|            ds->back_preroll = 0; // auto
 1070|  45.5k|        break;
 1071|  80.6k|    }
 1072|       |
 1073|  80.6k|    if (!ds->sh->attached_picture) {
  ------------------
  |  Branch (1073:9): [True: 80.6k, False: 0]
  ------------------
 1074|       |        // Typically this is used for webradio, so any stream will do.
 1075|  80.6k|        if (!in->metadata_stream)
  ------------------
  |  Branch (1075:13): [True: 57.0k, False: 23.5k]
  ------------------
 1076|  57.0k|            in->metadata_stream = sh;
 1077|  80.6k|    }
 1078|       |
 1079|  80.6k|    in->events |= DEMUX_EVENT_STREAMS;
 1080|  80.6k|    if (in->wakeup_cb)
  ------------------
  |  Branch (1080:9): [True: 65, False: 80.6k]
  ------------------
 1081|     65|        in->wakeup_cb(in->wakeup_cb_ctx);
 1082|  80.6k|}
demux.c:add_missing_streams:
  984|  57.5k|{
  985|   138k|    for (int n = range->num_streams; n < in->num_streams; n++) {
  ------------------
  |  Branch (985:38): [True: 80.6k, False: 57.5k]
  ------------------
  986|  80.6k|        struct demux_stream *ds = in->streams[n]->ds;
  987|       |
  988|  80.6k|        struct demux_queue *queue = talloc_ptrtype(NULL, queue);
  ------------------
  |  |   34|  80.6k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  80.6k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  80.6k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  989|  80.6k|        *queue = (struct demux_queue){
  990|  80.6k|            .ds = ds,
  991|  80.6k|            .range = range,
  992|  80.6k|        };
  993|  80.6k|        clear_queue(queue);
  994|  80.6k|        MP_TARRAY_APPEND(range, range->streams, range->num_streams, queue);
  ------------------
  |  |  105|  80.6k|    do {                                            \
  |  |  106|  80.6k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  80.6k|    do {                                            \
  |  |  |  |   97|  80.6k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  80.6k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  80.6k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  80.6k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 58.5k, False: 22.1k]
  |  |  |  |  ------------------
  |  |  |  |   99|  80.6k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  58.5k|    do {                                                        \
  |  |  |  |  |  |   89|  58.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  58.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  58.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  58.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  58.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  58.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  58.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 58.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  80.6k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 80.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  80.6k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  80.6k|        (idxvar)++;                                 \
  |  |  109|  80.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 80.6k]
  |  |  ------------------
  ------------------
  995|       |        mp_assert(range->streams[ds->index] == queue);
  ------------------
  |  |   41|  80.6k|#define mp_assert assert
  ------------------
  |  Branch (995:9): [True: 80.6k, False: 0]
  ------------------
  996|  80.6k|    }
  997|  57.5k|}
demux.c:clear_queue:
  758|   244k|{
  759|   244k|    struct demux_stream *ds = queue->ds;
  760|   244k|    struct demux_internal *in = ds->in;
  761|       |
  762|   244k|    if (queue->head)
  ------------------
  |  Branch (762:9): [True: 0, False: 244k]
  ------------------
  763|      0|        in->total_bytes -= queue->tail_cum_pos - queue->head->cum_pos;
  764|       |
  765|   244k|    free_index(queue);
  766|       |
  767|   244k|    demux_packet_pool_prepend(in->packet_pool, queue->head, queue->tail);
  768|   244k|    queue->head = queue->tail = NULL;
  769|   244k|    queue->keyframe_first = NULL;
  770|   244k|    queue->keyframe_latest = NULL;
  771|   244k|    queue->seek_start = queue->seek_end = queue->last_pruned = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   244k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  772|       |
  773|   244k|    queue->correct_dts = queue->correct_pos = true;
  774|   244k|    queue->last_pos = -1;
  775|   244k|    queue->last_ts = queue->last_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   244k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  776|   244k|    queue->last_pos_fixup = -1;
  777|       |
  778|   244k|    queue->is_eof = false;
  779|       |    queue->is_bof = false;
  780|   244k|}
demux.c:free_index:
  746|   244k|{
  747|   244k|    struct demux_stream *ds = queue->ds;
  748|   244k|    struct demux_internal *in = ds->in;
  749|       |
  750|   244k|    in->total_bytes -= queue->index_size * sizeof(queue->index[0]);
  751|   244k|    queue->index_size = 0;
  752|   244k|    queue->index0 = 0;
  753|   244k|    queue->num_index = 0;
  754|       |    TA_FREEP(&queue->index);
  ------------------
  |  |   81|   244k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   244k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 244k]
  |  |  ------------------
  ------------------
  755|   244k|}
demux.c:demux_shutdown:
 1120|   412k|{
 1121|   412k|    struct demuxer *demuxer = in->d_user;
 1122|       |
 1123|   412k|    if (in->recorder) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 412k]
  ------------------
 1124|      0|        mp_recorder_destroy(in->recorder);
 1125|      0|        in->recorder = NULL;
 1126|      0|    }
 1127|       |
 1128|   412k|    dumper_close(in);
 1129|       |
 1130|   412k|    if (demuxer->desc->close)
  ------------------
  |  Branch (1130:9): [True: 167k, False: 245k]
  ------------------
 1131|   167k|        demuxer->desc->close(in->d_thread);
 1132|   412k|    demuxer->priv = NULL;
 1133|   412k|    in->d_thread->priv = NULL;
 1134|       |
 1135|   412k|    demux_flush(demuxer);
 1136|   412k|    mp_assert(in->total_bytes == 0);
  ------------------
  |  |   41|   412k|#define mp_assert assert
  ------------------
  |  Branch (1136:5): [True: 412k, False: 18.4E]
  ------------------
 1137|       |
 1138|   412k|    in->current_range = NULL;
 1139|   412k|    free_empty_cached_ranges(in);
 1140|       |
 1141|   412k|    talloc_free(in->cache);
  ------------------
  |  |   47|   412k|#define talloc_free                     ta_free
  ------------------
 1142|   412k|    in->cache = NULL;
 1143|       |
 1144|   412k|    if (in->owns_stream)
  ------------------
  |  Branch (1144:9): [True: 412k, False: 0]
  ------------------
 1145|   412k|        free_stream(demuxer->stream);
 1146|       |    demuxer->stream = NULL;
 1147|   412k|}
demux.c:demux_dealloc:
 1150|   412k|{
 1151|   492k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (1151:21): [True: 80.6k, False: 412k]
  ------------------
 1152|  80.6k|        talloc_free(in->streams[n]);
  ------------------
  |  |   47|  80.6k|#define talloc_free                     ta_free
  ------------------
 1153|   412k|    mp_mutex_destroy(&in->lock);
  ------------------
  |  |  133|   412k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1154|   412k|    mp_cond_destroy(&in->wakeup);
 1155|   412k|    talloc_free(in->d_user);
  ------------------
  |  |   47|   412k|#define talloc_free                     ta_free
  ------------------
 1156|   412k|}
demux.c:append_field:
 1325|  65.2k|{
 1326|  65.2k|    if (skip_dup && skip_dup[0] && strstr(skip_dup, value))
  ------------------
  |  Branch (1326:9): [True: 0, False: 65.2k]
  |  Branch (1326:21): [True: 0, False: 0]
  |  Branch (1326:36): [True: 0, False: 0]
  ------------------
 1327|      0|        return;
 1328|  65.2k|    bstr_xappend_asprintf(ta_ctx, dst, " %s", value);
 1329|  65.2k|}
demux.c:add_packet_locked:
 2153|   875k|{
 2154|   875k|    struct demux_stream *ds = stream ? stream->ds : NULL;
  ------------------
  |  Branch (2154:31): [True: 875k, False: 1]
  ------------------
 2155|   875k|    mp_assert(ds && ds->in);
  ------------------
  |  |   41|   875k|#define mp_assert assert
  ------------------
  |  Branch (2155:5): [True: 875k, False: 0]
  |  Branch (2155:5): [True: 875k, False: 0]
  ------------------
 2156|   875k|    if (!dp->len || demux_cancel_test(ds->in->d_thread)) {
  ------------------
  |  Branch (2156:9): [True: 75, False: 875k]
  |  Branch (2156:21): [True: 18.4E, False: 875k]
  ------------------
 2157|     75|        talloc_free(dp);
  ------------------
  |  |   47|     75|#define talloc_free                     ta_free
  ------------------
 2158|     75|        return;
 2159|     75|    }
 2160|       |
 2161|   875k|    mp_assert(dp->stream == stream->index);
  ------------------
  |  |   41|   875k|#define mp_assert assert
  ------------------
  |  Branch (2161:5): [True: 875k, False: 18.4E]
  ------------------
 2162|   875k|    mp_assert(!dp->next);
  ------------------
  |  |   41|   875k|#define mp_assert assert
  ------------------
  |  Branch (2162:5): [True: 875k, False: 18.4E]
  ------------------
 2163|       |
 2164|   875k|    struct demux_internal *in = ds->in;
 2165|       |
 2166|   875k|    in->after_seek = false;
 2167|   875k|    in->after_seek_to_start = false;
 2168|       |
 2169|   875k|    double ts = dp->dts == MP_NOPTS_VALUE ? dp->pts : dp->dts;
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2169:17): [True: 1, False: 875k]
  ------------------
 2170|   875k|    if (dp->segmented)
  ------------------
  |  Branch (2170:9): [True: 0, False: 875k]
  ------------------
 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|   875k|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2173:9): [True: 875k, False: 6]
  ------------------
 2174|   875k|        in->demux_ts = ts;
 2175|       |
 2176|   875k|    struct demux_queue *queue = ds->queue;
 2177|       |
 2178|   875k|    bool drop = !ds->selected || in->seeking || ds->sh->attached_picture;
  ------------------
  |  Branch (2178:17): [True: 4, False: 875k]
  |  Branch (2178:34): [True: 18.4E, False: 875k]
  |  Branch (2178:49): [True: 18.4E, False: 875k]
  ------------------
 2179|       |
 2180|   875k|    if (!drop) {
  ------------------
  |  Branch (2180:9): [True: 875k, False: 1]
  ------------------
 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|   875k|        if ((dp->pos < 0 || dp->pos == queue->last_pos_fixup) &&
  ------------------
  |  Branch (2183:14): [True: 812k, False: 63.0k]
  |  Branch (2183:29): [True: 800, False: 62.2k]
  ------------------
 2184|   813k|            !dp->keyframe && queue->last_pos_fixup >= 0)
  ------------------
  |  Branch (2184:13): [True: 0, False: 813k]
  |  Branch (2184:30): [True: 0, False: 0]
  ------------------
 2185|      0|            dp->pos = queue->last_pos_fixup + 1;
 2186|   875k|        queue->last_pos_fixup = dp->pos;
 2187|   875k|    }
 2188|       |
 2189|   875k|    if (!drop && ds->refreshing) {
  ------------------
  |  Branch (2189:9): [True: 875k, False: 3]
  |  Branch (2189:18): [True: 0, False: 875k]
  ------------------
 2190|       |        // Resume reading once the old position was reached (i.e. we start
 2191|       |        // returning packets where we left off before the refresh).
 2192|       |        // If it's the same position, drop, but continue normally next time.
 2193|      0|        if (queue->correct_dts) {
  ------------------
  |  Branch (2193:13): [True: 0, False: 0]
  ------------------
 2194|      0|            ds->refreshing = dp->dts < queue->last_dts;
 2195|      0|        } else if (queue->correct_pos) {
  ------------------
  |  Branch (2195:20): [True: 0, False: 0]
  ------------------
 2196|      0|            ds->refreshing = dp->pos < queue->last_pos;
 2197|      0|        } else {
 2198|      0|            ds->refreshing = false; // should not happen
 2199|      0|            MP_WARN(in, "stream %d: demux refreshing failed\n", ds->index);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2200|      0|        }
 2201|      0|        drop = true;
 2202|      0|    }
 2203|       |
 2204|   875k|    if (drop) {
  ------------------
  |  Branch (2204:9): [True: 0, False: 875k]
  ------------------
 2205|      0|        demux_packet_pool_push(in->packet_pool, dp);
 2206|      0|        return;
 2207|      0|    }
 2208|       |
 2209|   875k|    record_packet(in, dp);
 2210|       |
 2211|   875k|    if (in->cache && in->d_user->opts->disk_cache && !dp->is_wrapped_avframe) {
  ------------------
  |  Branch (2211:9): [True: 0, False: 875k]
  |  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|   875k|    queue->correct_pos &= dp->pos >= 0 && dp->pos > queue->last_pos;
  ------------------
  |  Branch (2220:27): [True: 63.0k, False: 812k]
  |  Branch (2220:43): [True: 59.8k, False: 3.15k]
  ------------------
 2221|   875k|    queue->correct_dts &= dp->dts != MP_NOPTS_VALUE && dp->dts > queue->last_dts;
  ------------------
  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2221:27): [True: 875k, False: 5]
  |  Branch (2221:56): [True: 821k, False: 54.4k]
  ------------------
 2222|   875k|    queue->last_pos = dp->pos;
 2223|   875k|    queue->last_dts = dp->dts;
 2224|   875k|    ds->global_correct_pos &= queue->correct_pos;
 2225|   875k|    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|   875k|    if (!ds->reader_head && (!ds->skip_to_keyframe || dp->keyframe)) {
  ------------------
  |  Branch (2229:9): [True: 69.3k, False: 806k]
  |  Branch (2229:30): [True: 69.3k, False: 0]
  |  Branch (2229:55): [True: 0, False: 0]
  ------------------
 2230|  69.3k|        ds->reader_head = dp;
 2231|  69.3k|        ds->skip_to_keyframe = false;
 2232|  69.3k|    }
 2233|       |
 2234|   875k|    size_t bytes = demux_packet_estimate_total_size(dp);
 2235|   875k|    in->total_bytes += bytes;
 2236|   875k|    dp->cum_pos = queue->tail_cum_pos;
 2237|   875k|    queue->tail_cum_pos += bytes;
 2238|       |
 2239|   875k|    if (queue->tail) {
  ------------------
  |  Branch (2239:9): [True: 806k, False: 69.3k]
  ------------------
 2240|       |        // next packet in stream
 2241|   806k|        queue->tail->next = dp;
 2242|   806k|        queue->tail = dp;
 2243|   806k|    } else {
 2244|       |        // first packet in stream
 2245|  69.3k|        queue->head = queue->tail = dp;
 2246|  69.3k|    }
 2247|       |
 2248|   875k|    if (!ds->ignore_eof) {
  ------------------
  |  Branch (2248:9): [True: 875k, False: 20]
  ------------------
 2249|       |        // obviously not true anymore
 2250|   875k|        ds->eof = false;
 2251|   875k|        in->eof = false;
 2252|   875k|    }
 2253|       |
 2254|       |    // For video, PTS determination is not trivial, but for other media types
 2255|       |    // distinguishing PTS and DTS is not useful.
 2256|   875k|    if (stream->type != STREAM_VIDEO && dp->pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  63.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2256:9): [True: 63.0k, False: 812k]
  |  Branch (2256:41): [True: 1, False: 63.0k]
  ------------------
 2257|      1|        dp->pts = dp->dts;
 2258|       |
 2259|   875k|    if (ts != MP_NOPTS_VALUE && (ts > queue->last_ts || ts + 10 < queue->last_ts))
  ------------------
  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2259:9): [True: 875k, False: 18]
  |  Branch (2259:34): [True: 821k, False: 54.4k]
  |  Branch (2259:57): [True: 0, False: 54.4k]
  ------------------
 2260|   821k|        queue->last_ts = ts;
 2261|   875k|    if (ds->base_ts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2261:9): [True: 37.5k, False: 838k]
  ------------------
 2262|  37.5k|        ds->base_ts = queue->last_ts;
 2263|       |
 2264|   875k|    const char *num_pkts = queue->head == queue->tail ? "1" : ">1";
  ------------------
  |  Branch (2264:28): [True: 69.3k, False: 806k]
  ------------------
 2265|   875k|    uint64_t fw_bytes = get_forward_buffered_bytes(ds);
 2266|   875k|    MP_TRACE(in, "append packet to %s: size=%zu pts=%f dts=%f pos=%"PRIi64" "
  ------------------
  |  |   94|   875k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   875k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2267|   875k|             "[num=%s size=%zd]\n", stream_type_name(stream->type),
 2268|   875k|             dp->len, dp->pts, dp->dts, dp->pos, num_pkts, (size_t)fw_bytes);
 2269|       |
 2270|   875k|    adjust_seek_range_on_packet(ds, dp);
 2271|       |
 2272|       |    // May need to reduce backward cache.
 2273|   875k|    prune_old_packets(in);
 2274|       |
 2275|       |    // Possibly update duration based on highest TS demuxed (but ignore subs).
 2276|   875k|    if (stream->type != STREAM_SUB) {
  ------------------
  |  Branch (2276:9): [True: 812k, False: 63.0k]
  ------------------
 2277|   812k|        if (dp->segmented)
  ------------------
  |  Branch (2277:13): [True: 0, False: 812k]
  ------------------
 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|   812k|        if (ts > in->highest_av_pts) {
  ------------------
  |  Branch (2279:13): [True: 812k, False: 0]
  ------------------
 2280|   812k|            in->highest_av_pts = ts;
 2281|   812k|            double duration = in->highest_av_pts - in->d_thread->start_time;
 2282|   812k|            if (duration > in->d_thread->duration) {
  ------------------
  |  Branch (2282:17): [True: 812k, False: 0]
  ------------------
 2283|   812k|                in->d_thread->duration = duration;
 2284|       |                // (Don't wakeup user thread, would be too noisy.)
 2285|   812k|                in->events |= DEMUX_EVENT_DURATION;
 2286|   812k|                in->duration = duration;
 2287|   812k|            }
 2288|   812k|        }
 2289|   812k|    }
 2290|       |
 2291|       |    // Don't process the packet further if it's skipped by the previous seek
 2292|       |    // (see reader_head check/assignment above).
 2293|   875k|    if (!ds->reader_head)
  ------------------
  |  Branch (2293:9): [True: 0, False: 875k]
  ------------------
 2294|      0|        return;
 2295|       |
 2296|   875k|    back_demux_see_packets(ds);
 2297|       |
 2298|   875k|    wakeup_ds(ds);
 2299|   875k|}
demux.c:record_packet:
 2122|   875k|{
 2123|       |    // (should preferably be outside of the lock)
 2124|   875k|    if (in->enable_recording && !in->recorder &&
  ------------------
  |  Branch (2124:9): [True: 0, False: 875k]
  |  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|   875k|    if (in->recorder) {
  ------------------
  |  Branch (2136:9): [True: 0, False: 875k]
  ------------------
 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|   875k|    if (in->dumper_status == CONTROL_OK)
  ------------------
  |  |   95|   875k|#define CONTROL_OK 1
  ------------------
  |  Branch (2148:9): [True: 0, False: 875k]
  ------------------
 2149|      0|        write_dump_packet(in, dp);
 2150|   875k|}
demux.c:adjust_seek_range_on_packet:
 2015|   915k|{
 2016|   915k|    struct demux_queue *queue = ds->queue;
 2017|       |
 2018|   915k|    if (!ds->in->seekable_cache)
  ------------------
  |  Branch (2018:9): [True: 915k, False: 0]
  ------------------
 2019|   915k|        return;
 2020|       |
 2021|   915k|    bool new_eof = !dp;
 2022|      0|    bool update_ranges = queue->is_eof != new_eof;
 2023|      0|    queue->is_eof = new_eof;
 2024|       |
 2025|      0|    if (!dp || dp->keyframe) {
  ------------------
  |  Branch (2025:9): [True: 0, False: 0]
  |  Branch (2025:16): [True: 0, False: 0]
  ------------------
 2026|      0|        if (queue->keyframe_latest) {
  ------------------
  |  Branch (2026:13): [True: 0, False: 0]
  ------------------
 2027|      0|            double kf_min, kf_max;
 2028|      0|            compute_keyframe_times(queue->keyframe_latest, &kf_min, &kf_max);
 2029|       |
 2030|      0|            if (kf_min != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2030:17): [True: 0, False: 0]
  ------------------
 2031|      0|                add_index_entry(queue, queue->keyframe_latest, kf_min);
 2032|       |
 2033|       |                // Initialize the queue's start if it's unset.
 2034|      0|                if (queue->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2034:21): [True: 0, False: 0]
  ------------------
 2035|      0|                    update_ranges = true;
 2036|      0|                    queue->seek_start = kf_min + ds->sh->seek_preroll;
 2037|       |
 2038|       |                    // queue->is_bof is set optimistically after a seek to start,
 2039|       |                    // assuming demuxing began at the start of the file. That is
 2040|       |                    // wrong for streams opened mid-content, which can happen in
 2041|       |                    // unfinished event HLS playlists, which starts at live-edge,
 2042|       |                    // but the seekable range in the past is still valid.
 2043|      0|                    double start_time = ds->in->d_thread->start_time;
 2044|      0|                    if (queue->is_bof && ds->in->d_thread->seekable &&
  ------------------
  |  Branch (2044:25): [True: 0, False: 0]
  |  Branch (2044:42): [True: 0, False: 0]
  ------------------
 2045|      0|                        start_time != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2045:25): [True: 0, False: 0]
  ------------------
 2046|      0|                        queue->seek_start > start_time + BOF_START_TOLERANCE)
  ------------------
  |  |  348|      0|#define BOF_START_TOLERANCE 1.0
  ------------------
  |  Branch (2046:25): [True: 0, False: 0]
  ------------------
 2047|      0|                    {
 2048|      0|                        queue->is_bof = false;
 2049|      0|                    }
 2050|      0|                }
 2051|      0|            }
 2052|       |
 2053|      0|            if (kf_max != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2053:17): [True: 0, False: 0]
  ------------------
 2054|      0|                (queue->seek_end == MP_NOPTS_VALUE || kf_max > queue->seek_end))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2054:18): [True: 0, False: 0]
  |  Branch (2054:55): [True: 0, False: 0]
  ------------------
 2055|      0|            {
 2056|       |                // If the queue was past the current range's end even before
 2057|       |                // this update, it means _other_ streams are not there yet,
 2058|       |                // and the seek range doesn't need to be updated. This means
 2059|       |                // if the _old_ queue->seek_end was already after the range end,
 2060|       |                // then the new seek_end won't extend the range either.
 2061|      0|                if (queue->range->seek_end == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2061:21): [True: 0, False: 0]
  ------------------
 2062|      0|                    queue->seek_end <= queue->range->seek_end)
  ------------------
  |  Branch (2062:21): [True: 0, False: 0]
  ------------------
 2063|      0|                {
 2064|      0|                    update_ranges = true;
 2065|      0|                }
 2066|       |
 2067|      0|                queue->seek_end = kf_max;
 2068|      0|            }
 2069|      0|        }
 2070|       |
 2071|      0|        queue->keyframe_latest = dp;
 2072|      0|    }
 2073|       |
 2074|       |    // Adding a sparse packet never changes the seek range.
 2075|      0|    if (update_ranges && ds->eager) {
  ------------------
  |  Branch (2075:9): [True: 0, False: 0]
  |  Branch (2075:26): [True: 0, False: 0]
  ------------------
 2076|      0|        update_seek_ranges(queue->range);
 2077|      0|        attempt_range_joining(ds->in);
 2078|      0|    }
 2079|      0|}
demux.c:update_seek_ranges:
  629|   226k|{
  630|   226k|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   226k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  631|   226k|    range->is_bof = true;
  632|   226k|    range->is_eof = true;
  633|       |
  634|   226k|    double min_start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   226k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  635|   226k|    double max_end_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   226k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  636|       |
  637|   308k|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (637:21): [True: 272k, False: 36.7k]
  ------------------
  638|   272k|        struct demux_queue *queue = range->streams[n];
  639|       |
  640|   272k|        if (queue->ds->selected && queue->ds->eager) {
  ------------------
  |  Branch (640:13): [True: 189k, False: 82.9k]
  |  Branch (640:36): [True: 189k, False: 0]
  ------------------
  641|   189k|            if (queue->is_bof) {
  ------------------
  |  Branch (641:17): [True: 65, False: 189k]
  ------------------
  642|     65|                min_start_pts = MP_PTS_MIN(min_start_pts, queue->seek_start);
  ------------------
  |  |   64|     65|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|    130|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 65]
  |  |  |  |  |  Branch (45:23): [True: 65, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 65, False: 0]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 65, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|   189k|            } else {
  644|   189k|                range->seek_start =
  645|   189k|                    MP_PTS_MAX(range->seek_start, queue->seek_start);
  ------------------
  |  |   65|   189k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|   378k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 189k]
  |  |  |  |  |  Branch (44:23): [True: 189k, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 189k, False: 0]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 189k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|   189k|            }
  647|       |
  648|   189k|            if (queue->is_eof) {
  ------------------
  |  Branch (648:17): [True: 0, False: 189k]
  ------------------
  649|      0|                max_end_pts = MP_PTS_MAX(max_end_pts, queue->seek_end);
  ------------------
  |  |   65|      0|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:23): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|   189k|            } else {
  651|   189k|                range->seek_end = MP_PTS_MIN(range->seek_end, queue->seek_end);
  ------------------
  |  |   64|   189k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|   378k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 189k]
  |  |  |  |  |  Branch (45:23): [True: 189k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 189k, False: 0]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 189k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|   189k|            }
  653|       |
  654|   189k|            range->is_eof &= queue->is_eof;
  655|   189k|            range->is_bof &= queue->is_bof;
  656|       |
  657|   189k|            bool empty = queue->is_eof && !queue->head;
  ------------------
  |  Branch (657:26): [True: 0, False: 189k]
  |  Branch (657:43): [True: 0, False: 0]
  ------------------
  658|   189k|            if (queue->seek_start >= queue->seek_end && !empty &&
  ------------------
  |  Branch (658:17): [True: 189k, False: 0]
  |  Branch (658:57): [True: 189k, False: 0]
  ------------------
  659|   189k|                !(queue->seek_start == queue->seek_end &&
  ------------------
  |  Branch (659:19): [True: 189k, False: 0]
  ------------------
  660|   189k|                  queue->seek_start != MP_NOPTS_VALUE))
  ------------------
  |  |   39|   189k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (660:19): [True: 0, False: 189k]
  ------------------
  661|   189k|                goto broken;
  662|   189k|        }
  663|   272k|    }
  664|       |
  665|  36.7k|    if (range->is_eof)
  ------------------
  |  Branch (665:9): [True: 36.7k, False: 0]
  ------------------
  666|  36.7k|        range->seek_end = max_end_pts;
  667|  36.7k|    if (range->is_bof)
  ------------------
  |  Branch (667:9): [True: 36.7k, False: 0]
  ------------------
  668|  36.7k|        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|   119k|    for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (694:21): [True: 82.3k, False: 36.7k]
  ------------------
  695|  82.3k|        struct demux_queue *queue = range->streams[n];
  696|  82.3k|        if (queue->ds->selected && !queue->ds->eager &&
  ------------------
  |  Branch (696:13): [True: 0, False: 82.3k]
  |  Branch (696:36): [True: 0, False: 0]
  ------------------
  697|      0|            queue->last_pruned != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  82.3k|#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|  82.3k|    }
  706|       |
  707|  36.7k|    if (range->seek_start >= range->seek_end && !(range->is_bof && range->is_eof))
  ------------------
  |  Branch (707:9): [True: 36.7k, False: 0]
  |  Branch (707:51): [True: 36.7k, False: 0]
  |  Branch (707:68): [True: 36.7k, False: 0]
  ------------------
  708|      0|        goto broken;
  709|       |
  710|  36.7k|    prune_metadata(range);
  711|  36.7k|    return;
  712|       |
  713|   189k|broken:
  714|   189k|    range->seek_start = range->seek_end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   189k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  715|   189k|    prune_metadata(range);
  716|   189k|}
demux.c:prune_metadata:
  603|   226k|{
  604|   226k|    int first_needed = 0;
  605|       |
  606|   226k|    if (range->seek_start == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   226k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (606:9): [True: 226k, False: 0]
  ------------------
  607|   226k|        first_needed = range->num_metadata;
  608|   226k|    } else {
  609|      0|        for (int n = 0; n < range->num_metadata ; n++) {
  ------------------
  |  Branch (609:25): [True: 0, False: 0]
  ------------------
  610|      0|            if (range->metadata[n]->pts > range->seek_start)
  ------------------
  |  Branch (610:17): [True: 0, False: 0]
  ------------------
  611|      0|                break;
  612|      0|            first_needed = n;
  613|      0|        }
  614|      0|    }
  615|       |
  616|       |    // Always preserve the last entry.
  617|   226k|    first_needed = MPMIN(first_needed, range->num_metadata - 1);
  ------------------
  |  |   45|   226k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 226k, 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|   226k|    for (int n = 0; n < first_needed; n++) {
  ------------------
  |  Branch (621:21): [True: 0, False: 226k]
  ------------------
  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|   226k|}
demux.c:remove_head_packet:
  720|   875k|{
  721|   875k|    struct demux_packet *dp = queue->head;
  722|       |
  723|   875k|    mp_assert(queue->ds->reader_head != dp);
  ------------------
  |  |   41|   875k|#define mp_assert assert
  ------------------
  |  Branch (723:5): [True: 875k, False: 0]
  ------------------
  724|   875k|    if (queue->keyframe_first == dp)
  ------------------
  |  Branch (724:9): [True: 806k, False: 69.3k]
  ------------------
  725|   806k|        queue->keyframe_first = NULL;
  726|   875k|    if (queue->keyframe_latest == dp)
  ------------------
  |  Branch (726:9): [True: 0, False: 875k]
  ------------------
  727|      0|        queue->keyframe_latest = NULL;
  728|   875k|    queue->is_bof = false;
  729|       |
  730|   875k|    uint64_t end_pos = dp->next ? dp->next->cum_pos : queue->tail_cum_pos;
  ------------------
  |  Branch (730:24): [True: 806k, False: 69.3k]
  ------------------
  731|   875k|    queue->ds->in->total_bytes -= end_pos - dp->cum_pos;
  732|       |
  733|   875k|    if (queue->num_index && queue->index[queue->index0].pkt == dp) {
  ------------------
  |  Branch (733:9): [True: 0, False: 875k]
  |  Branch (733:29): [True: 0, False: 0]
  ------------------
  734|      0|        queue->index0 = (queue->index0 + 1) & QUEUE_INDEX_SIZE_MASK(queue);
  ------------------
  |  |  335|      0|#define QUEUE_INDEX_SIZE_MASK(queue) ((queue)->index_size - 1)
  ------------------
  735|      0|        queue->num_index -= 1;
  736|      0|    }
  737|       |
  738|   875k|    queue->head = dp->next;
  739|   875k|    if (!queue->head)
  ------------------
  |  Branch (739:9): [True: 69.3k, False: 806k]
  ------------------
  740|  69.3k|        queue->tail = NULL;
  741|       |
  742|   875k|    demux_packet_pool_push(queue->ds->in->packet_pool, dp);
  743|   875k|}
demux.c:prune_old_packets:
 2465|  1.80M|{
 2466|  1.80M|    mp_assert(in->current_range == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|  1.80M|#define mp_assert assert
  ------------------
  |  Branch (2466:5): [True: 1.80M, False: 1]
  ------------------
 2467|       |
 2468|       |    // It's not clear what the ideal way to prune old packets is. For now, we
 2469|       |    // prune the oldest packet runs, as long as the total cache amount is too
 2470|       |    // big.
 2471|  2.68M|    while (1) {
  ------------------
  |  Branch (2471:12): [True: 2.68M, Folded]
  ------------------
 2472|  2.68M|        uint64_t fw_bytes = 0;
 2473|  5.39M|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2473:25): [True: 2.70M, False: 2.68M]
  ------------------
 2474|  2.70M|            struct demux_stream *ds = in->streams[n]->ds;
 2475|  2.70M|            fw_bytes += get_forward_buffered_bytes(ds);
 2476|  2.70M|        }
 2477|  2.68M|        uint64_t max_avail = in->max_bytes_bw;
 2478|       |        // Backward cache (if enabled at all) can use unused forward cache.
 2479|       |        // Still leave 1 byte free, so the read_packet logic doesn't get stuck.
 2480|  2.68M|        if (max_avail && in->max_bytes > (fw_bytes + 1) && in->d_user->opts->donate_fw)
  ------------------
  |  Branch (2480:13): [True: 0, False: 2.68M]
  |  Branch (2480:26): [True: 0, False: 0]
  |  Branch (2480:60): [True: 0, False: 0]
  ------------------
 2481|      0|            max_avail += in->max_bytes - (fw_bytes + 1);
 2482|  2.68M|        if (in->total_bytes - fw_bytes <= max_avail)
  ------------------
  |  Branch (2482:13): [True: 1.80M, False: 875k]
  ------------------
 2483|  1.80M|            break;
 2484|       |
 2485|       |        // (Start from least recently used range.)
 2486|   875k|        struct demux_cached_range *range = in->ranges[0];
 2487|   875k|        double earliest_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2488|   875k|        struct demux_stream *earliest_stream = NULL;
 2489|       |
 2490|   875k|        for (int n = 0; n < range->num_streams; n++) {
  ------------------
  |  Branch (2490:25): [True: 875k, False: 2]
  ------------------
 2491|   875k|            struct demux_queue *queue = range->streams[n];
 2492|   875k|            struct demux_stream *ds = queue->ds;
 2493|       |
 2494|   875k|            if (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2494:17): [True: 875k, False: 0]
  |  Branch (2494:32): [True: 875k, False: 0]
  ------------------
 2495|   875k|                struct demux_packet *dp = queue->head;
 2496|   875k|                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|   875k|                bool prune_always =
 2501|   875k|                    !in->seekable_cache || ts == MP_NOPTS_VALUE || !dp->keyframe;
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2501:21): [True: 875k, False: 0]
  |  Branch (2501:44): [True: 0, False: 0]
  |  Branch (2501:68): [True: 0, False: 0]
  ------------------
 2502|   875k|                if (prune_always || !earliest_stream || ts < earliest_ts) {
  ------------------
  |  Branch (2502:21): [True: 875k, False: 0]
  |  Branch (2502:37): [True: 0, False: 0]
  |  Branch (2502:57): [True: 0, False: 0]
  ------------------
 2503|   875k|                    earliest_ts = ts;
 2504|   875k|                    earliest_stream = ds;
 2505|   875k|                    if (prune_always)
  ------------------
  |  Branch (2505:25): [True: 875k, False: 0]
  ------------------
 2506|   875k|                        break;
 2507|   875k|                }
 2508|   875k|            }
 2509|   875k|        }
 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|   875k|        if (!earliest_stream)
  ------------------
  |  Branch (2513:13): [True: 0, False: 875k]
  ------------------
 2514|      0|            break;
 2515|       |
 2516|   875k|        struct demux_stream *ds = earliest_stream;
 2517|   875k|        struct demux_queue *queue = range->streams[ds->index];
 2518|       |
 2519|   875k|        bool non_kf_prune = queue->head && !queue->head->keyframe;
  ------------------
  |  Branch (2519:29): [True: 875k, False: 2]
  |  Branch (2519:44): [True: 0, False: 875k]
  ------------------
 2520|   875k|        bool kf_was_pruned = false;
 2521|       |
 2522|  1.75M|        while (queue->head && queue->head != ds->reader_head) {
  ------------------
  |  Branch (2522:16): [True: 1.68M, False: 69.3k]
  |  Branch (2522:31): [True: 875k, False: 806k]
  ------------------
 2523|   875k|            if (queue->head->keyframe) {
  ------------------
  |  Branch (2523:17): [True: 875k, 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|   875k|                if ((kf_was_pruned || non_kf_prune) && in->seekable_cache)
  ------------------
  |  Branch (2530:22): [True: 0, False: 875k]
  |  Branch (2530:39): [True: 0, False: 875k]
  |  Branch (2530:56): [True: 0, False: 0]
  ------------------
 2531|      0|                    break;
 2532|   875k|                kf_was_pruned = true;
 2533|   875k|            }
 2534|       |
 2535|   875k|            remove_head_packet(queue);
 2536|   875k|        }
 2537|       |
 2538|       |        // Need to update the seekable time range.
 2539|   875k|        if (kf_was_pruned) {
  ------------------
  |  Branch (2539:13): [True: 875k, False: 2]
  ------------------
 2540|   875k|            mp_assert(!queue->keyframe_first); // it was just deleted, supposedly
  ------------------
  |  |   41|   875k|#define mp_assert assert
  ------------------
  |  Branch (2540:13): [True: 875k, False: 0]
  ------------------
 2541|       |
 2542|   875k|            queue->keyframe_first = queue->head;
 2543|       |            // (May happen if reader_head stopped pruning the range, and there's
 2544|       |            // no next range.)
 2545|   875k|            while (queue->keyframe_first && !queue->keyframe_first->keyframe)
  ------------------
  |  Branch (2545:20): [True: 806k, False: 69.3k]
  |  Branch (2545:45): [True: 0, False: 806k]
  ------------------
 2546|      0|                queue->keyframe_first = queue->keyframe_first->next;
 2547|       |
 2548|   875k|            if (queue->seek_start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2548:17): [True: 806k, False: 69.3k]
  ------------------
 2549|   806k|                queue->last_pruned = queue->seek_start;
 2550|       |
 2551|   875k|            double kf_min;
 2552|   875k|            compute_keyframe_times(queue->keyframe_first, &kf_min, NULL);
 2553|       |
 2554|   875k|            bool update_range = true;
 2555|       |
 2556|   875k|            queue->seek_start = kf_min;
 2557|       |
 2558|   875k|            if (queue->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2558:17): [True: 806k, False: 69.3k]
  ------------------
 2559|   806k|                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|   806k|                if (range->seek_start == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|  1.61M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2563:21): [True: 806k, False: 0]
  ------------------
 2564|      0|                    queue->seek_start <= range->seek_start)
  ------------------
  |  Branch (2564:21): [True: 0, False: 0]
  ------------------
 2565|   806k|                {
 2566|   806k|                    update_range = false;
 2567|   806k|                }
 2568|   806k|            }
 2569|       |
 2570|   875k|            if (update_range)
  ------------------
  |  Branch (2570:17): [True: 69.3k, False: 806k]
  ------------------
 2571|  69.3k|                update_seek_ranges(range);
 2572|   875k|        }
 2573|       |
 2574|   875k|        if (range != in->current_range && range->seek_start == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2574:13): [True: 0, False: 875k]
  |  Branch (2574:43): [True: 0, False: 0]
  ------------------
 2575|      0|            free_empty_cached_ranges(in);
 2576|   875k|    }
 2577|  1.80M|}
demux.c:back_demux_see_packets:
 1713|   915k|{
 1714|   915k|    struct demux_internal *in = ds->in;
 1715|       |
 1716|   915k|    if (!ds->selected || !in->back_demuxing || !ds->eager)
  ------------------
  |  Branch (1716:9): [True: 375, False: 915k]
  |  Branch (1716:26): [True: 915k, False: 0]
  |  Branch (1716:48): [True: 0, False: 0]
  ------------------
 1717|   915k|        return;
 1718|       |
 1719|      0|    mp_assert(!(ds->back_resuming && ds->back_restarting));
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1719:5): [True: 0, False: 0]
  |  Branch (1719:5): [True: 0, False: 0]
  ------------------
 1720|       |
 1721|      0|    if (!ds->global_correct_dts && !ds->global_correct_pos) {
  ------------------
  |  Branch (1721:9): [True: 0, False: 0]
  |  Branch (1721:36): [True: 0, False: 0]
  ------------------
 1722|      0|        MP_ERR(in, "Can't demux backward due to demuxer problems.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1723|      0|        error_on_backward_demuxing(in);
 1724|      0|        return;
 1725|      0|    }
 1726|       |
 1727|      0|    while (ds->back_resuming && ds->reader_head) {
  ------------------
  |  Branch (1727:12): [True: 0, False: 0]
  |  Branch (1727:33): [True: 0, False: 0]
  ------------------
 1728|      0|        struct demux_packet *head = ds->reader_head;
 1729|      0|        if ((ds->global_correct_dts && head->dts == ds->back_resume_dts) ||
  ------------------
  |  Branch (1729:14): [True: 0, False: 0]
  |  Branch (1729:40): [True: 0, False: 0]
  ------------------
 1730|      0|            (ds->global_correct_pos && head->pos == ds->back_resume_pos))
  ------------------
  |  Branch (1730:14): [True: 0, False: 0]
  |  Branch (1730:40): [True: 0, False: 0]
  ------------------
 1731|      0|        {
 1732|      0|            ds->back_resuming = false;
 1733|      0|            ds->need_wakeup = true;
 1734|      0|            wakeup_ds(ds); // probably
 1735|      0|            break;
 1736|      0|        }
 1737|      0|        advance_reader_head(ds);
 1738|      0|    }
 1739|       |
 1740|      0|    if (ds->back_restarting)
  ------------------
  |  Branch (1740:9): [True: 0, False: 0]
  ------------------
 1741|      0|        find_backward_restart_pos(ds);
 1742|      0|}
demux.c:advance_reader_head:
 2778|   875k|{
 2779|   875k|    struct demux_packet *pkt = ds->reader_head;
 2780|   875k|    if (!pkt)
  ------------------
  |  Branch (2780:9): [True: 0, False: 875k]
  ------------------
 2781|      0|        return NULL;
 2782|       |
 2783|   875k|    ds->reader_head = pkt->next;
 2784|       |
 2785|   875k|    ds->last_ret_pos = pkt->pos;
 2786|   875k|    ds->last_ret_dts = pkt->dts;
 2787|       |
 2788|   875k|    return pkt;
 2789|   875k|}
demux.c:ds_clear_reader_state:
  842|   202k|{
  843|   202k|    ds_clear_reader_queue_state(ds);
  844|       |
  845|   202k|    ds->base_ts = ds->last_br_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   202k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  846|   202k|    ds->last_br_bytes = 0;
  847|   202k|    ds->bitrate = -1;
  848|   202k|    ds->skip_to_keyframe = false;
  849|   202k|    ds->attached_picture_added = false;
  850|   202k|    ds->lazy_eof = false;
  851|   202k|    ds->last_ret_pos = -1;
  852|   202k|    ds->last_ret_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   202k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  853|   202k|    ds->force_read_until = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   202k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  854|       |
  855|   202k|    if (clear_back_state) {
  ------------------
  |  Branch (855:9): [True: 202k, False: 0]
  ------------------
  856|   202k|        ds->back_restart_pos = -1;
  857|   202k|        ds->back_restart_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   202k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  858|   202k|        ds->back_restart_eof = false;
  859|   202k|        ds->back_restart_next = ds->in->back_demuxing;
  860|   202k|        ds->back_restarting = ds->in->back_demuxing && ds->eager;
  ------------------
  |  Branch (860:31): [True: 0, False: 202k]
  |  Branch (860:56): [True: 0, False: 0]
  ------------------
  861|   202k|        ds->back_seek_pos = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   202k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  862|   202k|        ds->back_resume_pos = -1;
  863|   202k|        ds->back_resume_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   202k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  864|   202k|        ds->back_resuming = false;
  865|       |        ds->back_range_started = false;
  866|   202k|        ds->back_range_count = 0;
  867|   202k|        ds->back_range_preroll = 0;
  868|   202k|    }
  869|   202k|}
demux.c:ds_clear_reader_queue_state:
  834|   202k|{
  835|   202k|    ds->reader_head = NULL;
  836|   202k|    ds->eof = false;
  837|       |    ds->need_wakeup = true;
  838|   202k|}
demux.c:demux_thread:
 2747|  55.1k|{
 2748|  55.1k|    struct demux_internal *in = pctx;
 2749|  55.1k|    mp_thread_set_name("demux");
 2750|  55.1k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  55.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2751|       |
 2752|  55.1k|    stats_register_thread_cputime(in->stats, "thread");
 2753|       |
 2754|  1.13M|    while (!in->thread_terminate) {
  ------------------
  |  Branch (2754:12): [True: 1.07M, False: 55.1k]
  ------------------
 2755|  1.07M|        if (thread_work(in))
  ------------------
  |  Branch (2755:13): [True: 944k, False: 133k]
  ------------------
 2756|   944k|            continue;
 2757|   133k|        mp_cond_signal(&in->wakeup);
 2758|   133k|        mp_cond_timedwait_until(&in->wakeup, &in->lock, in->next_cache_update);
 2759|   133k|    }
 2760|       |
 2761|  55.1k|    if (in->shutdown_async) {
  ------------------
  |  Branch (2761:9): [True: 36.8k, False: 18.3k]
  ------------------
 2762|  36.8k|        mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  36.8k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2763|  36.8k|        demux_shutdown(in);
 2764|  36.8k|        mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  36.8k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2765|  36.8k|        in->shutdown_async = false;
 2766|  36.8k|        if (in->wakeup_cb)
  ------------------
  |  Branch (2766:13): [True: 36.8k, False: 18.4E]
  ------------------
 2767|  36.8k|            in->wakeup_cb(in->wakeup_cb_ctx);
 2768|  36.8k|    }
 2769|       |
 2770|  55.1k|    stats_unregister_thread(in->stats, "thread");
 2771|       |
 2772|  55.1k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  55.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2773|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  55.1k|#define MP_THREAD_RETURN() return NULL
  ------------------
 2774|  55.1k|}
demux.c:dequeue_packet:
 2823|  1.46M|{
 2824|  1.46M|    struct demux_internal *in = ds->in;
 2825|       |
 2826|  1.46M|    if (!ds->selected)
  ------------------
  |  Branch (2826:9): [True: 0, False: 1.46M]
  ------------------
 2827|      0|        return -1;
 2828|  1.46M|    if (in->blocked)
  ------------------
  |  Branch (2828:9): [True: 0, False: 1.46M]
  ------------------
 2829|      0|        return 0;
 2830|       |
 2831|  1.46M|    if (ds->sh->attached_picture) {
  ------------------
  |  Branch (2831:9): [True: 0, False: 1.46M]
  ------------------
 2832|      0|        ds->eof = true;
 2833|      0|        if (ds->attached_picture_added)
  ------------------
  |  Branch (2833:13): [True: 0, False: 0]
  ------------------
 2834|      0|            return -1;
 2835|      0|        ds->attached_picture_added = true;
 2836|      0|        struct demux_packet *pkt = demux_copy_packet(in->packet_pool,
 2837|      0|                                                     ds->sh->attached_picture);
 2838|      0|        MP_HANDLE_OOM(pkt);
  ------------------
  |  |  206|      0|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|      0|        void *oom_p_ = (x);     \
  |  |  208|      0|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  209|      0|            abort();            \
  |  |  210|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2839|      0|        pkt->stream = ds->sh->index;
 2840|      0|        *res = pkt;
 2841|      0|        return 1;
 2842|      0|    }
 2843|       |
 2844|  1.46M|    if (!in->reading && !in->eof) {
  ------------------
  |  Branch (2844:9): [True: 1.38M, False: 78.7k]
  |  Branch (2844:25): [True: 62.7k, False: 1.32M]
  ------------------
 2845|  62.7k|        in->reading = true; // enable demuxer thread prefetching
 2846|  62.7k|        mp_cond_signal(&in->wakeup);
 2847|  62.7k|    }
 2848|       |
 2849|  1.46M|    ds->force_read_until = min_pts;
 2850|       |
 2851|  1.46M|    if (ds->back_resuming || ds->back_restarting) {
  ------------------
  |  Branch (2851:9): [True: 0, False: 1.46M]
  |  Branch (2851:30): [True: 0, False: 1.46M]
  ------------------
 2852|      0|        mp_assert(in->back_demuxing);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (2852:9): [True: 0, False: 0]
  ------------------
 2853|      0|        return 0;
 2854|      0|    }
 2855|       |
 2856|  1.46M|    bool eof = !ds->reader_head && ds->eof;
  ------------------
  |  Branch (2856:16): [True: 592k, False: 875k]
  |  Branch (2856:36): [True: 537k, False: 54.8k]
  ------------------
 2857|       |
 2858|  1.46M|    if (in->back_demuxing) {
  ------------------
  |  Branch (2858:9): [True: 0, False: 1.46M]
  ------------------
 2859|       |        // Subtitles not supported => EOF.
 2860|      0|        if (!ds->eager)
  ------------------
  |  Branch (2860:13): [True: 0, False: 0]
  ------------------
 2861|      0|            return -1;
 2862|       |
 2863|       |        // Next keyframe (or EOF) was reached => step back.
 2864|      0|        if (ds->back_range_started && !ds->back_range_count &&
  ------------------
  |  Branch (2864:13): [True: 0, False: 0]
  |  Branch (2864:39): [True: 0, False: 0]
  ------------------
 2865|      0|            ((ds->reader_head && ds->reader_head->keyframe) || eof))
  ------------------
  |  Branch (2865:15): [True: 0, False: 0]
  |  Branch (2865:34): [True: 0, False: 0]
  |  Branch (2865:64): [True: 0, False: 0]
  ------------------
 2866|      0|        {
 2867|      0|            ds->back_restarting = true;
 2868|      0|            ds->back_restart_eof = false;
 2869|      0|            ds->back_restart_next = false;
 2870|       |
 2871|      0|            find_backward_restart_pos(ds);
 2872|       |
 2873|      0|            if (ds->back_restarting)
  ------------------
  |  Branch (2873:17): [True: 0, False: 0]
  ------------------
 2874|      0|                return 0;
 2875|      0|        }
 2876|       |
 2877|      0|        eof = ds->back_range_count < 0;
 2878|      0|    }
 2879|       |
 2880|  1.46M|    ds->need_wakeup = !ds->reader_head;
 2881|  1.46M|    if (!ds->reader_head || eof) {
  ------------------
  |  Branch (2881:9): [True: 592k, False: 875k]
  |  Branch (2881:29): [True: 0, False: 875k]
  ------------------
 2882|   592k|        if (!ds->eager) {
  ------------------
  |  Branch (2882:13): [True: 0, False: 592k]
  ------------------
 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|   592k|        if (eof)
  ------------------
  |  Branch (2895:13): [True: 537k, False: 54.8k]
  ------------------
 2896|   537k|            ds->lazy_eof = !in->eof && !in->back_demuxing;
  ------------------
  |  Branch (2896:28): [True: 0, False: 537k]
  |  Branch (2896:40): [True: 0, False: 0]
  ------------------
 2897|   592k|        return eof ? -1 : 0;
  ------------------
  |  Branch (2897:16): [True: 537k, False: 54.8k]
  ------------------
 2898|   592k|    }
 2899|       |
 2900|   875k|    struct demux_packet *pkt = advance_reader_head(ds);
 2901|   875k|    mp_assert(pkt);
  ------------------
  |  |   41|   875k|#define mp_assert assert
  ------------------
  |  Branch (2901:5): [True: 875k, False: 0]
  ------------------
 2902|   875k|    pkt = read_packet_from_cache(in, pkt);
 2903|   875k|    if (!pkt)
  ------------------
  |  Branch (2903:9): [True: 0, False: 875k]
  ------------------
 2904|      0|        return 0;
 2905|   875k|    ds->lazy_eof = false;
 2906|       |
 2907|   875k|    if (in->back_demuxing) {
  ------------------
  |  Branch (2907:9): [True: 0, False: 875k]
  ------------------
 2908|      0|        if (pkt->keyframe) {
  ------------------
  |  Branch (2908:13): [True: 0, False: 0]
  ------------------
 2909|      0|            mp_assert(ds->back_range_count > 0);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (2909:13): [True: 0, False: 0]
  ------------------
 2910|      0|            ds->back_range_count -= 1;
 2911|      0|            if (ds->back_range_preroll >= 0)
  ------------------
  |  Branch (2911:17): [True: 0, False: 0]
  ------------------
 2912|      0|                ds->back_range_preroll -= 1;
 2913|      0|        }
 2914|       |
 2915|      0|        if (ds->back_range_preroll >= 0)
  ------------------
  |  Branch (2915:13): [True: 0, False: 0]
  ------------------
 2916|      0|            pkt->back_preroll = true;
 2917|       |
 2918|      0|        if (!ds->back_range_started) {
  ------------------
  |  Branch (2918:13): [True: 0, False: 0]
  ------------------
 2919|      0|            pkt->back_restart = true;
 2920|      0|            ds->back_range_started = true;
 2921|      0|        }
 2922|      0|    }
 2923|       |
 2924|   875k|    double ts = MP_PTS_OR_DEF(pkt->dts, pkt->pts);
  ------------------
  |  |   62|   875k|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 1, False: 875k]
  |  |  ------------------
  ------------------
 2925|   875k|    if (ts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2925:9): [True: 875k, False: 1]
  ------------------
 2926|   875k|        ds->base_ts = ts;
 2927|       |
 2928|   875k|    if (pkt->keyframe && ts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2928:9): [True: 875k, False: 0]
  |  Branch (2928:26): [True: 875k, False: 1]
  ------------------
 2929|       |        // Update bitrate - only at keyframe points, because we use the
 2930|       |        // (possibly) reordered packet timestamps instead of realtime.
 2931|   875k|        double d = ts - ds->last_br_ts;
 2932|   875k|        if (ds->last_br_ts == MP_NOPTS_VALUE || d < 0) {
  ------------------
  |  |   39|  1.75M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2932:13): [True: 37.5k, False: 838k]
  |  Branch (2932:49): [True: 0, False: 838k]
  ------------------
 2933|  37.5k|            ds->bitrate = -1;
 2934|  37.5k|            ds->last_br_ts = ts;
 2935|  37.5k|            ds->last_br_bytes = 0;
 2936|   838k|        } else if (d >= 0.5) { // a window of least 500ms for UI purposes
  ------------------
  |  Branch (2936:20): [True: 35.2k, False: 803k]
  ------------------
 2937|  35.2k|            ds->bitrate = ds->last_br_bytes / d;
 2938|  35.2k|            ds->last_br_ts = ts;
 2939|  35.2k|            ds->last_br_bytes = 0;
 2940|  35.2k|        }
 2941|   875k|    }
 2942|   875k|    ds->last_br_bytes += pkt->len;
 2943|       |
 2944|       |    // This implies this function is actually called from "the" user thread.
 2945|   875k|    if (pkt->pos >= in->d_user->filepos)
  ------------------
  |  Branch (2945:9): [True: 842k, False: 32.9k]
  ------------------
 2946|   842k|        in->d_user->filepos = pkt->pos;
 2947|   875k|    in->d_user->filesize = in->stream_size;
 2948|       |
 2949|   875k|    pkt->pts = MP_ADD_PTS(pkt->pts, in->ts_offset);
  ------------------
  |  |   67|   875k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 1, False: 875k]
  |  |  ------------------
  ------------------
 2950|   875k|    pkt->dts = MP_ADD_PTS(pkt->dts, in->ts_offset);
  ------------------
  |  |   67|   875k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 1, False: 875k]
  |  |  ------------------
  ------------------
 2951|       |
 2952|   875k|    if (pkt->segmented) {
  ------------------
  |  Branch (2952:9): [True: 0, False: 875k]
  ------------------
 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|   875k|    prune_old_packets(in);
 2958|   875k|    *res = pkt;
 2959|   875k|    return 1;
 2960|   875k|}
demux.c:lazy_stream_needs_wait:
 2312|  2.17k|{
 2313|  2.17k|    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|  2.17k|    return !ds->eager && !in->back_demuxing &&
  ------------------
  |  Branch (2316:12): [True: 2.17k, False: 0]
  |  Branch (2316:26): [True: 2.17k, False: 0]
  ------------------
 2317|  2.17k|           !in->eof && ds->force_read_until != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  4.34k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2317:12): [True: 2.17k, False: 0]
  |  Branch (2317:24): [True: 0, False: 2.17k]
  ------------------
 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|  2.17k|}
demux.c:read_packet_from_cache:
 2796|   875k|{
 2797|   875k|    if (!pkt)
  ------------------
  |  Branch (2797:9): [True: 0, False: 875k]
  ------------------
 2798|      0|        return NULL;
 2799|       |
 2800|   875k|    if (pkt->is_cached) {
  ------------------
  |  Branch (2800:9): [True: 0, False: 875k]
  ------------------
 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|   875k|    } else {
 2810|       |        // The returned packet is mutated etc. and will be owned by the user.
 2811|   875k|        pkt = demux_copy_packet(in->packet_pool, pkt);
 2812|   875k|    }
 2813|       |
 2814|   875k|    return pkt;
 2815|   875k|}
demux.c:thread_work:
 2708|  1.09M|{
 2709|  1.09M|    struct demux_opts *opts = in->d_user->opts;
 2710|  1.09M|    size_t old_max_bytes = opts->max_bytes;
 2711|  1.09M|    size_t old_max_bytes_bw = opts->max_bytes_bw;
 2712|  1.09M|    if (m_config_cache_update(in->d_user->opts_cache)) {
  ------------------
  |  Branch (2712:9): [True: 0, False: 1.09M]
  ------------------
 2713|      0|        update_opts(in->d_user);
 2714|      0|        if (opts->max_bytes + opts->max_bytes_bw < old_max_bytes + old_max_bytes_bw)
  ------------------
  |  Branch (2714:13): [True: 0, False: 0]
  ------------------
 2715|      0|            demux_packet_pool_clear(in->packet_pool);
 2716|      0|    }
 2717|  1.09M|    if (in->tracks_switched) {
  ------------------
  |  Branch (2717:9): [True: 36.8k, False: 1.05M]
  ------------------
 2718|  36.8k|        execute_trackswitch(in);
 2719|  36.8k|        return true;
 2720|  36.8k|    }
 2721|  1.05M|    if (in->nav_refresh) {
  ------------------
  |  Branch (2721:9): [True: 0, False: 1.05M]
  ------------------
 2722|      0|        execute_nav_refresh(in);
 2723|      0|        return true;
 2724|      0|    }
 2725|  1.05M|    if (in->need_back_seek) {
  ------------------
  |  Branch (2725:9): [True: 0, False: 1.05M]
  ------------------
 2726|      0|        perform_backward_seek(in);
 2727|      0|        return true;
 2728|      0|    }
 2729|  1.05M|    if (in->back_any_need_recheck) {
  ------------------
  |  Branch (2729:9): [True: 0, False: 1.05M]
  ------------------
 2730|      0|        check_backward_seek(in);
 2731|      0|        return true;
 2732|      0|    }
 2733|  1.05M|    if (in->seeking) {
  ------------------
  |  Branch (2733:9): [True: 4.33k, False: 1.04M]
  ------------------
 2734|  4.33k|        execute_seek(in);
 2735|  4.33k|        return true;
 2736|  4.33k|    }
 2737|  1.04M|    if (read_packet(in))
  ------------------
  |  Branch (2737:9): [True: 915k, False: 133k]
  ------------------
 2738|   915k|        return true; // read_packet unlocked, so recheck conditions
 2739|   133k|    if (mp_time_ns() >= in->next_cache_update) {
  ------------------
  |  Branch (2739:9): [True: 0, False: 133k]
  ------------------
 2740|      0|        update_cache(in);
 2741|      0|        return true;
 2742|      0|    }
 2743|   133k|    return false;
 2744|   133k|}
demux.c:update_opts:
 2638|  57.5k|{
 2639|  57.5k|    struct demux_opts *opts = demuxer->opts;
 2640|  57.5k|    struct demux_internal *in = demuxer->in;
 2641|       |
 2642|  57.5k|    in->min_secs = opts->min_secs;
 2643|  57.5k|    in->hyst_secs = opts->hyst_secs;
 2644|  57.5k|    in->hyst_bytes = opts->hyst_bytes;
 2645|  57.5k|    in->max_bytes = opts->max_bytes;
 2646|  57.5k|    in->max_bytes_bw = opts->max_bytes_bw;
 2647|       |
 2648|  57.5k|    int seekable = opts->seekable_cache;
 2649|  57.5k|    bool is_streaming = in->d_thread->is_streaming;
 2650|  57.5k|    bool use_cache = is_streaming;
 2651|  57.5k|    if (opts->enable_cache >= 0)
  ------------------
  |  Branch (2651:9): [True: 0, False: 57.5k]
  ------------------
 2652|      0|        use_cache = opts->enable_cache == 1;
 2653|       |
 2654|  57.5k|    if (use_cache) {
  ------------------
  |  Branch (2654:9): [True: 0, False: 57.5k]
  ------------------
 2655|      0|        in->min_secs = MPMAX(in->min_secs, opts->min_secs_cache);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2656|      0|        if (seekable < 0)
  ------------------
  |  Branch (2656:13): [True: 0, False: 0]
  ------------------
 2657|      0|            seekable = 1;
 2658|      0|    }
 2659|  57.5k|    in->seekable_cache = seekable == 1;
 2660|  57.5k|    if (in->d_thread->no_cache_seeking)
  ------------------
  |  Branch (2660:9): [True: 0, False: 57.5k]
  ------------------
 2661|      0|        in->seekable_cache = false;
 2662|  57.5k|    in->using_network_cache_opts = is_streaming && use_cache;
  ------------------
  |  Branch (2662:36): [True: 0, False: 57.5k]
  |  Branch (2662:52): [True: 0, False: 0]
  ------------------
 2663|       |
 2664|  57.5k|    if (!in->seekable_cache)
  ------------------
  |  Branch (2664:9): [True: 57.5k, False: 0]
  ------------------
 2665|  57.5k|        in->max_bytes_bw = 0;
 2666|       |
 2667|  57.5k|    if (!in->can_cache) {
  ------------------
  |  Branch (2667:9): [True: 0, False: 57.5k]
  ------------------
 2668|      0|        in->seekable_cache = false;
 2669|      0|        in->min_secs = 0;
 2670|      0|        in->max_bytes = 1;
 2671|      0|        in->max_bytes_bw = 0;
 2672|      0|        in->using_network_cache_opts = false;
 2673|      0|    }
 2674|       |
 2675|  57.5k|    if (in->seekable_cache && opts->disk_cache && !in->cache) {
  ------------------
  |  Branch (2675:9): [True: 0, False: 57.5k]
  |  Branch (2675:31): [True: 0, False: 0]
  |  Branch (2675:51): [True: 0, False: 0]
  ------------------
 2676|      0|        in->cache = demux_cache_create(in->global, in->log);
 2677|      0|        if (!in->cache)
  ------------------
  |  Branch (2677:13): [True: 0, False: 0]
  ------------------
 2678|      0|            MP_ERR(in, "Failed to create file cache.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2679|      0|    }
 2680|       |
 2681|       |    // The filename option really decides whether recording should be active.
 2682|       |    // So if the filename changes, act upon it.
 2683|  57.5k|    char *old = in->record_filename ? in->record_filename : "";
  ------------------
  |  Branch (2683:17): [True: 0, False: 57.5k]
  ------------------
 2684|  57.5k|    char *new = opts->record_file ? opts->record_file : "";
  ------------------
  |  Branch (2684:17): [True: 0, False: 57.5k]
  ------------------
 2685|  57.5k|    if (strcmp(old, new) != 0) {
  ------------------
  |  Branch (2685:9): [True: 0, False: 57.5k]
  ------------------
 2686|      0|        if (in->recorder) {
  ------------------
  |  Branch (2686:13): [True: 0, False: 0]
  ------------------
 2687|      0|            MP_WARN(in, "Stopping recording.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2688|      0|            mp_recorder_destroy(in->recorder);
 2689|      0|            in->recorder = NULL;
 2690|      0|        }
 2691|      0|        talloc_free(in->record_filename);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2692|      0|        in->record_filename = talloc_strdup(in, opts->record_file);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 2693|       |        // Note: actual recording only starts once packets are read. It may be
 2694|       |        // important to delay creating in->recorder to that point, because the
 2695|       |        // demuxer might detect more streams until finding the first packet.
 2696|      0|        in->enable_recording = in->can_record;
 2697|      0|    }
 2698|       |
 2699|       |    // In case the cache was reduced in size.
 2700|  57.5k|    prune_old_packets(in);
 2701|       |
 2702|       |    // In case the seekable cache was disabled.
 2703|  57.5k|    free_empty_cached_ranges(in);
 2704|  57.5k|}
demux.c:execute_seek:
 2604|  6.68k|{
 2605|  6.68k|    int flags = in->seek_flags;
 2606|  6.68k|    double pts = in->seek_pts;
 2607|  6.68k|    in->eof = false;
 2608|  6.68k|    in->seeking = false;
 2609|  6.68k|    in->seeking_in_progress = pts;
 2610|  6.68k|    in->demux_ts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  6.68k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2611|  6.68k|    in->low_level_seeks += 1;
 2612|  6.68k|    in->after_seek = true;
 2613|  6.68k|    in->after_seek_to_start =
 2614|  6.68k|        !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   95|  6.68k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
                      !(flags & (SEEK_FORWARD | SEEK_FACTOR)) &&
  ------------------
  |  |   94|  6.68k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (2614:9): [True: 6.68k, False: 0]
  ------------------
 2615|  6.68k|        pts <= in->d_thread->start_time;
  ------------------
  |  Branch (2615:9): [True: 6.68k, False: 0]
  ------------------
 2616|       |
 2617|  13.7k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2617:21): [True: 7.05k, False: 6.68k]
  ------------------
 2618|  7.05k|        in->streams[n]->ds->queue->last_pos_fixup = -1;
 2619|       |
 2620|  6.68k|    if (in->recorder)
  ------------------
  |  Branch (2620:9): [True: 0, False: 6.68k]
  ------------------
 2621|      0|        mp_recorder_mark_discontinuity(in->recorder);
 2622|       |
 2623|  6.68k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  6.68k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2624|       |
 2625|  6.68k|    MP_VERBOSE(in, "execute seek (to %f flags %d)\n", pts, flags);
  ------------------
  |  |   92|  6.68k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.68k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2626|       |
 2627|  6.68k|    if (in->d_thread->desc->seek)
  ------------------
  |  Branch (2627:9): [True: 6.68k, False: 0]
  ------------------
 2628|  6.68k|        in->d_thread->desc->seek(in->d_thread, pts, flags);
 2629|       |
 2630|  6.68k|    MP_VERBOSE(in, "seek done\n");
  ------------------
  |  |   92|  6.68k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.68k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2631|       |
 2632|  6.68k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  6.68k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2633|       |
 2634|  6.68k|    in->seeking_in_progress = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  6.68k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 2635|  6.68k|}
demux.c:read_packet:
 2324|  1.04M|{
 2325|  1.04M|    bool was_reading = in->reading;
 2326|  1.04M|    in->reading = false;
 2327|       |
 2328|  1.04M|    if (!was_reading || in->blocked || demux_cancel_test(in->d_thread))
  ------------------
  |  Branch (2328:9): [True: 110k, False: 939k]
  |  Branch (2328:25): [True: 18.4E, False: 939k]
  |  Branch (2328:40): [True: 1, False: 939k]
  ------------------
 2329|   110k|        return false;
 2330|       |
 2331|       |    // Check if we need to read a new packet. We do this if all queues are below
 2332|       |    // the minimum, or if a stream explicitly needs new packets. Also includes
 2333|       |    // safe-guards against packet queue overflow.
 2334|  1.04M|    bool read_more = false, prefetch_more = false, refresh_more = false;
 2335|   939k|    uint64_t total_fw_bytes = 0;
 2336|  1.88M|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2336:21): [True: 941k, False: 939k]
  ------------------
 2337|   941k|        total_fw_bytes += get_forward_buffered_bytes(in->streams[n]->ds);
 2338|   939k|    if (in->hyst_bytes > 0 && total_fw_bytes <= in->hyst_bytes)
  ------------------
  |  Branch (2338:9): [True: 0, False: 939k]
  |  Branch (2338:31): [True: 0, False: 0]
  ------------------
 2339|      0|        in->hyst_active = false;
 2340|  1.88M|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2340:21): [True: 941k, False: 939k]
  ------------------
 2341|   941k|        struct demux_stream *ds = in->streams[n]->ds;
 2342|   941k|        if (ds->eager) {
  ------------------
  |  Branch (2342:13): [True: 939k, False: 2.16k]
  ------------------
 2343|   939k|            read_more |= !ds->reader_head;
 2344|   939k|            if (in->back_demuxing)
  ------------------
  |  Branch (2344:17): [True: 0, False: 939k]
  ------------------
 2345|      0|                read_more |= ds->back_restarting || ds->back_resuming;
  ------------------
  |  Branch (2345:30): [True: 0, False: 0]
  |  Branch (2345:53): [True: 0, False: 0]
  ------------------
 2346|   939k|        } else {
 2347|  2.16k|            if (lazy_stream_needs_wait(ds)) {
  ------------------
  |  Branch (2347:17): [True: 0, False: 2.16k]
  ------------------
 2348|      0|                read_more = true;
 2349|  2.16k|            } else {
 2350|  2.16k|                mark_stream_eof(ds); // let playback continue
 2351|  2.16k|            }
 2352|  2.16k|        }
 2353|   941k|        refresh_more |= ds->refreshing;
 2354|   941k|        if (ds->eager && ds->queue->last_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  1.88M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2354:13): [True: 939k, False: 2.16k]
  |  Branch (2354:26): [True: 899k, False: 39.8k]
  ------------------
 2355|   899k|            in->min_secs > 0 && ds->base_ts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  1.84M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2355:13): [True: 899k, False: 0]
  |  Branch (2355:33): [True: 899k, False: 1]
  ------------------
 2356|   899k|            ds->queue->last_ts >= ds->base_ts &&
  ------------------
  |  Branch (2356:13): [True: 899k, False: 18.4E]
  ------------------
 2357|   899k|            !in->back_demuxing)
  ------------------
  |  Branch (2357:13): [True: 899k, False: 0]
  ------------------
 2358|   899k|        {
 2359|   899k|            if (ds->queue->last_ts - ds->base_ts <= in->hyst_secs)
  ------------------
  |  Branch (2359:17): [True: 76.2k, False: 823k]
  ------------------
 2360|  76.2k|                in->hyst_active = false;
 2361|   899k|            if (!in->hyst_active)
  ------------------
  |  Branch (2361:17): [True: 899k, False: 0]
  ------------------
 2362|   899k|                prefetch_more |= ds->queue->last_ts - ds->base_ts < in->min_secs;
 2363|   899k|        }
 2364|   941k|    }
 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|   939k|    if (in->nav_active)
  ------------------
  |  Branch (2369:9): [True: 0, False: 939k]
  ------------------
 2370|      0|        prefetch_more = false;
 2371|   939k|    prefetch_more |= in->nav_pump;
 2372|       |
 2373|   939k|    MP_TRACE(in, "bytes=%zd, read_more=%d prefetch_more=%d, refresh_more=%d\n",
  ------------------
  |  |   94|   939k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   939k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2374|   939k|             (size_t)total_fw_bytes, read_more, prefetch_more, refresh_more);
 2375|   939k|    if (total_fw_bytes >= in->max_bytes) {
  ------------------
  |  Branch (2375:9): [True: 0, False: 939k]
  ------------------
 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|   939k|    if (!read_more && !prefetch_more && !refresh_more) {
  ------------------
  |  Branch (2410:9): [True: 887k, False: 51.8k]
  |  Branch (2410:23): [True: 23.5k, False: 863k]
  |  Branch (2410:41): [True: 23.5k, False: 0]
  ------------------
 2411|  23.5k|        in->hyst_active = in->hyst_secs > 0 || in->hyst_bytes > 0;
  ------------------
  |  Branch (2411:27): [True: 0, False: 23.5k]
  |  Branch (2411:48): [True: 0, False: 23.5k]
  ------------------
 2412|  23.5k|        return false;
 2413|  23.5k|    }
 2414|       |
 2415|   915k|    if (in->after_seek_to_start) {
  ------------------
  |  Branch (2415:9): [True: 39.1k, False: 876k]
  ------------------
 2416|  78.6k|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (2416:25): [True: 39.4k, False: 39.1k]
  ------------------
 2417|  39.4k|            struct demux_stream *ds = in->streams[n]->ds;
 2418|  39.4k|            in->current_range->streams[n]->is_bof =
 2419|  39.4k|                ds->selected && !ds->refreshing;
  ------------------
  |  Branch (2419:17): [True: 39.1k, False: 310]
  |  Branch (2419:33): [True: 39.1k, False: 0]
  ------------------
 2420|  39.4k|        }
 2421|  39.1k|    }
 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|   915k|    in->reading = true;
 2426|   915k|    in->nav_pump = false;
 2427|   915k|    in->after_seek = false;
 2428|   915k|    in->after_seek_to_start = false;
 2429|   915k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   915k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2430|       |
 2431|   915k|    struct demuxer *demux = in->d_thread;
 2432|   915k|    struct demux_packet *pkt = NULL;
 2433|       |
 2434|   915k|    bool eof = true;
 2435|   915k|    if (demux->desc->read_packet && !demux_read_interrupted(demux))
  ------------------
  |  Branch (2435:9): [True: 915k, False: 18.4E]
  |  Branch (2435:37): [True: 915k, False: 18.4E]
  ------------------
 2436|   915k|        eof = !demux->desc->read_packet(demux, &pkt);
 2437|       |
 2438|   915k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   915k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2439|   915k|    update_cache(in);
 2440|       |
 2441|   915k|    if (pkt) {
  ------------------
  |  Branch (2441:9): [True: 875k, False: 39.8k]
  ------------------
 2442|   875k|        mp_assert(pkt->stream >= 0 && pkt->stream < in->num_streams);
  ------------------
  |  |   41|   875k|#define mp_assert assert
  ------------------
  |  Branch (2442:9): [True: 875k, False: 0]
  |  Branch (2442:9): [True: 875k, False: 0]
  ------------------
 2443|   875k|        add_packet_locked(in->streams[pkt->stream], pkt);
 2444|   875k|    }
 2445|       |
 2446|   915k|    if (!in->seeking) {
  ------------------
  |  Branch (2446:9): [True: 915k, False: 18.4E]
  ------------------
 2447|   915k|        if (eof) {
  ------------------
  |  Branch (2447:13): [True: 39.1k, False: 876k]
  ------------------
 2448|  78.7k|            for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (2448:29): [True: 39.5k, False: 39.1k]
  ------------------
 2449|  39.5k|                mark_stream_eof(in->streams[n]->ds);
 2450|       |            // If we had EOF previously, then don't wakeup (avoids wakeup loop)
 2451|  39.1k|            if (!in->eof) {
  ------------------
  |  Branch (2451:17): [True: 39.1k, False: 0]
  ------------------
 2452|  39.1k|                if (in->wakeup_cb)
  ------------------
  |  Branch (2452:21): [True: 36.8k, False: 2.34k]
  ------------------
 2453|  36.8k|                    in->wakeup_cb(in->wakeup_cb_ctx);
 2454|  39.1k|                mp_cond_signal(&in->wakeup);
 2455|  39.1k|                MP_VERBOSE(in, "EOF reached.\n");
  ------------------
  |  |   92|  39.1k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  39.1k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2456|  39.1k|            }
 2457|  39.1k|        }
 2458|   915k|        in->eof = eof;
 2459|   915k|        in->reading = !eof;
 2460|   915k|    }
 2461|       |    return true;
 2462|   915k|}
demux.c:mark_stream_eof:
 2302|  41.7k|{
 2303|  41.7k|    if (!ds->eof) {
  ------------------
  |  Branch (2303:9): [True: 39.5k, False: 2.17k]
  ------------------
 2304|  39.5k|        ds->eof = true;
 2305|       |        adjust_seek_range_on_packet(ds, NULL);
 2306|  39.5k|        back_demux_see_packets(ds);
 2307|  39.5k|        wakeup_ds(ds);
 2308|  39.5k|    }
 2309|  41.7k|}
demux.c:lookup_timed_metadata:
 3374|  1.99M|{
 3375|  1.99M|    struct demux_cached_range *r = in->current_range;
 3376|       |
 3377|  1.99M|    if (!r || !r->num_metadata || pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3377:9): [True: 0, False: 1.99M]
  |  Branch (3377:15): [True: 1.99M, False: 0]
  |  Branch (3377:35): [True: 0, False: 0]
  ------------------
 3378|  1.99M|        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|  1.99M|}
demux.c:update_final_metadata:
 3331|  57.5k|{
 3332|  57.5k|    mp_assert(demuxer == demuxer->in->d_user);
  ------------------
  |  |   41|  57.5k|#define mp_assert assert
  ------------------
  |  Branch (3332:5): [True: 57.5k, False: 0]
  ------------------
 3333|  57.5k|    struct demux_internal *in = demuxer->in;
 3334|       |
 3335|  57.5k|    struct mp_tags *dyn_tags = NULL;
 3336|       |
 3337|       |    // Often useful for audio-only files, which have metadata in the audio track
 3338|       |    // metadata instead of the main metadata, but can also have cover art
 3339|       |    // metadata (which libavformat likes to treat as video streams).
 3340|  57.5k|    int astreams = 0;
 3341|  57.5k|    int astream_id = -1;
 3342|  57.5k|    int vstreams = 0;
 3343|   138k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3343:21): [True: 80.6k, False: 57.5k]
  ------------------
 3344|  80.6k|        struct sh_stream *sh = in->streams[n];
 3345|  80.6k|        if (sh->type == STREAM_VIDEO && !sh->attached_picture)
  ------------------
  |  Branch (3345:13): [True: 45.5k, False: 35.0k]
  |  Branch (3345:41): [True: 45.5k, False: 0]
  ------------------
 3346|  45.5k|            vstreams += 1;
 3347|  80.6k|        if (sh->type == STREAM_AUDIO) {
  ------------------
  |  Branch (3347:13): [True: 28.3k, False: 52.2k]
  ------------------
 3348|  28.3k|            astreams += 1;
 3349|  28.3k|            astream_id = n;
 3350|  28.3k|        }
 3351|  80.6k|    }
 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|  57.5k|    if (vstreams == 0 && astreams == 1 &&
  ------------------
  |  Branch (3356:9): [True: 12.7k, False: 44.7k]
  |  Branch (3356:26): [True: 5.27k, False: 7.52k]
  ------------------
 3357|  5.27k|        in->streams[astream_id] == in->metadata_stream)
  ------------------
  |  Branch (3357:9): [True: 5.24k, False: 23]
  ------------------
 3358|  5.24k|    {
 3359|  5.24k|        dyn_tags = in->metadata_stream->tags;
 3360|  5.24k|        if (tm && tm->from_stream)
  ------------------
  |  Branch (3360:13): [True: 0, False: 5.24k]
  |  Branch (3360:19): [True: 0, False: 0]
  ------------------
 3361|      0|            dyn_tags = tm->tags;
 3362|  5.24k|    }
 3363|       |
 3364|       |    // Global metadata updates.
 3365|  57.5k|    if (tm && !tm->from_stream)
  ------------------
  |  Branch (3365:9): [True: 0, False: 57.5k]
  |  Branch (3365:15): [True: 0, False: 0]
  ------------------
 3366|      0|        dyn_tags = tm->tags;
 3367|       |
 3368|  57.5k|    if (dyn_tags)
  ------------------
  |  Branch (3368:9): [True: 5.24k, False: 52.2k]
  ------------------
 3369|  5.24k|        mp_tags_merge(demuxer->metadata, dyn_tags);
 3370|  57.5k|}
demux.c:demux_update_replaygain:
 3167|  90.0k|{
 3168|  90.0k|    struct demux_internal *in = demuxer->in;
 3169|   203k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3169:21): [True: 113k, False: 90.0k]
  ------------------
 3170|   113k|        struct sh_stream *sh = in->streams[n];
 3171|   113k|        if (sh->type == STREAM_AUDIO && !sh->codec->replaygain_data) {
  ------------------
  |  Branch (3171:13): [True: 28.3k, False: 84.7k]
  |  Branch (3171:41): [True: 28.3k, False: 0]
  ------------------
 3172|  28.3k|            struct replaygain_data *rg = decode_rgain(demuxer->log, sh->tags);
 3173|  28.3k|            if (!rg)
  ------------------
  |  Branch (3173:17): [True: 28.3k, False: 0]
  ------------------
 3174|  28.3k|                rg = decode_rgain(demuxer->log, demuxer->metadata);
 3175|  28.3k|            if (rg)
  ------------------
  |  Branch (3175:17): [True: 0, False: 28.3k]
  ------------------
 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|  28.3k|        }
 3178|   113k|    }
 3179|  90.0k|}
demux.c:decode_rgain:
 3117|  56.7k|{
 3118|  56.7k|    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|  56.7k|    if (decode_gain(log, tags, "REPLAYGAIN_TRACK_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3124:9): [True: 0, False: 56.7k]
  ------------------
 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|  56.7k|    if (decode_gain(log, tags, "REPLAYGAIN_GAIN", &rg.track_gain) >= 0 &&
  ------------------
  |  Branch (3137:9): [True: 0, False: 56.7k]
  ------------------
 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|  56.7k|    if (decode_gain(log, tags, "R128_TRACK_GAIN", &rg.track_gain) >= 0) {
  ------------------
  |  Branch (3148:9): [True: 0, False: 56.7k]
  ------------------
 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|  56.7k|    return NULL;
 3164|  56.7k|}
demux.c:decode_gain:
 3079|   170k|{
 3080|   170k|    char *tag_val = NULL;
 3081|   170k|    float dec_val;
 3082|       |
 3083|   170k|    tag_val = mp_tags_get_str(tags, tag);
 3084|   170k|    if (!tag_val)
  ------------------
  |  Branch (3084:9): [True: 170k, False: 0]
  ------------------
 3085|   170k|        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|  65.0k|{
 3679|  65.0k|    const int *check_levels = d_normal;
 3680|  65.0k|    const struct demuxer_desc *check_desc = NULL;
 3681|  65.0k|    struct mp_log *log = mp_log_new(NULL, global->log, "!demux");
 3682|  65.0k|    struct demuxer *demuxer = NULL;
 3683|  65.0k|    char *force_format = params->force_format;
 3684|       |
 3685|  65.0k|    struct parent_stream_info sinfo = {
 3686|  65.0k|        .seekable = stream->seekable,
 3687|  65.0k|        .is_network = stream->is_network,
 3688|  65.0k|        .is_streaming = stream->streaming,
 3689|  65.0k|        .stream_origin = stream->stream_origin,
 3690|  65.0k|        .cancel = cancel,
 3691|  65.0k|        .filename = talloc_strdup(NULL, stream->url),
  ------------------
  |  |   50|  65.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3692|  65.0k|        .server_filename = stream->server_filename,
 3693|  65.0k|    };
 3694|       |
 3695|  65.0k|    if (!force_format)
  ------------------
  |  Branch (3695:9): [True: 65.0k, False: 0]
  ------------------
 3696|  65.0k|        force_format = stream->demuxer;
 3697|       |
 3698|  65.0k|    if (force_format && force_format[0] && !stream->is_directory) {
  ------------------
  |  Branch (3698:9): [True: 32.5k, False: 32.5k]
  |  Branch (3698:25): [True: 32.5k, False: 0]
  |  Branch (3698:44): [True: 32.5k, False: 0]
  ------------------
 3699|  32.5k|        check_levels = d_request;
 3700|  32.5k|        if (force_format[0] == '+') {
  ------------------
  |  Branch (3700:13): [True: 0, False: 32.5k]
  ------------------
 3701|      0|            force_format += 1;
 3702|      0|            check_levels = d_force;
 3703|      0|        }
 3704|   260k|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3704:25): [True: 260k, False: 0]
  ------------------
 3705|   260k|            if (strcmp(demuxer_list[n]->name, force_format) == 0) {
  ------------------
  |  Branch (3705:17): [True: 32.5k, False: 227k]
  ------------------
 3706|  32.5k|                check_desc = demuxer_list[n];
 3707|  32.5k|                break;
 3708|  32.5k|            }
 3709|   260k|        }
 3710|  32.5k|        if (!check_desc) {
  ------------------
  |  Branch (3710:13): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    }
 3715|       |
 3716|       |    // Test demuxers from first to last, one pass for each check_levels[] entry
 3717|  80.0k|    for (int pass = 0; check_levels[pass] != -1; pass++) {
  ------------------
  |  Branch (3717:24): [True: 72.5k, False: 7.50k]
  ------------------
 3718|  72.5k|        enum demux_check level = check_levels[pass];
 3719|  72.5k|        mp_verbose(log, "Trying demuxers for level=%s.\n", d_level(level));
  ------------------
  |  |   79|  72.5k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3720|   654k|        for (int n = 0; demuxer_list[n]; n++) {
  ------------------
  |  Branch (3720:25): [True: 639k, False: 15.0k]
  ------------------
 3721|   639k|            const struct demuxer_desc *desc = demuxer_list[n];
 3722|   639k|            if (!check_desc || desc == check_desc) {
  ------------------
  |  Branch (3722:17): [True: 379k, False: 260k]
  |  Branch (3722:32): [True: 32.5k, False: 227k]
  ------------------
 3723|   412k|                demuxer = open_given_type(global, log, desc, stream, &sinfo,
 3724|   412k|                                          params, level);
 3725|   412k|                if (demuxer) {
  ------------------
  |  Branch (3725:21): [True: 57.5k, False: 354k]
  ------------------
 3726|  57.5k|                    talloc_steal(demuxer, log);
  ------------------
  |  |   38|  57.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  57.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3727|  57.5k|                    log = NULL;
 3728|  57.5k|                    goto done;
 3729|  57.5k|                }
 3730|   412k|            }
 3731|   639k|        }
 3732|  72.5k|    }
 3733|       |
 3734|  65.0k|done:
 3735|  65.0k|    talloc_free(sinfo.filename);
  ------------------
  |  |   47|  65.0k|#define talloc_free                     ta_free
  ------------------
 3736|  65.0k|    talloc_free(log);
  ------------------
  |  |   47|  65.0k|#define talloc_free                     ta_free
  ------------------
 3737|  65.0k|    return demuxer;
 3738|  65.0k|}
demux.c:d_level:
 3054|   484k|{
 3055|   484k|    switch (level) {
  ------------------
  |  Branch (3055:13): [True: 484k, False: 0]
  ------------------
 3056|      0|    case DEMUX_CHECK_FORCE:  return "force";
  ------------------
  |  Branch (3056:5): [True: 0, False: 484k]
  ------------------
 3057|  97.5k|    case DEMUX_CHECK_UNSAFE: return "unsafe";
  ------------------
  |  Branch (3057:5): [True: 97.5k, False: 387k]
  ------------------
 3058|  65.0k|    case DEMUX_CHECK_REQUEST:return "request";
  ------------------
  |  Branch (3058:5): [True: 65.0k, False: 419k]
  ------------------
 3059|   322k|    case DEMUX_CHECK_NORMAL: return "normal";
  ------------------
  |  Branch (3059:5): [True: 322k, False: 162k]
  ------------------
 3060|   484k|    }
 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|   412k|{
 3542|   412k|    if (mp_cancel_test(sinfo->cancel))
  ------------------
  |  Branch (3542:9): [True: 0, False: 412k]
  ------------------
 3543|      0|        return NULL;
 3544|       |
 3545|   412k|    if (params->depth > 10) {
  ------------------
  |  Branch (3545:9): [True: 0, False: 412k]
  ------------------
 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|   412k|    mp_dbg(log, "Trying demuxer: %s (force-level: %s)\n",
  ------------------
  |  |   80|   412k|#define mp_dbg(log, ...)        mp_msg(log, MSGL_DEBUG, __VA_ARGS__)
  ------------------
 3551|   412k|           desc->name, d_level(check));
 3552|       |
 3553|   412k|    if (stream && !stream_seek(stream, 0)) {
  ------------------
  |  Branch (3553:9): [True: 412k, False: 0]
  |  Branch (3553:19): [True: 0, False: 412k]
  ------------------
 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|   412k|    struct demuxer *demuxer = talloc_ptrtype(NULL, demuxer);
  ------------------
  |  |   34|   412k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   412k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   412k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3559|   412k|    struct m_config_cache *opts_cache =
 3560|   412k|        m_config_cache_alloc(demuxer, global, &demux_conf);
 3561|   412k|    struct demux_opts *opts = opts_cache->opts;
 3562|   412k|    *demuxer = (struct demuxer) {
 3563|   412k|        .desc = desc,
 3564|   412k|        .stream = stream,
 3565|   412k|        .cancel = sinfo->cancel,
 3566|   412k|        .seekable = sinfo->seekable,
 3567|   412k|        .filepos = -1,
 3568|   412k|        .global = global,
 3569|   412k|        .log = mp_log_new(demuxer, log, desc->name),
 3570|   412k|        .packet_pool = demux_packet_pool_get(global),
 3571|   412k|        .glog = log,
 3572|   412k|        .filename = talloc_strdup(demuxer, sinfo->filename),
  ------------------
  |  |   50|   412k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3573|   412k|        .server_filename = talloc_strdup(demuxer, sinfo->server_filename),
  ------------------
  |  |   50|   412k|#define talloc_strdup                   ta_xstrdup
  ------------------
 3574|   412k|        .is_network = sinfo->is_network,
 3575|   412k|        .is_streaming = sinfo->is_streaming,
 3576|   412k|        .stream_origin = sinfo->stream_origin,
 3577|   412k|        .access_references = opts->access_references,
 3578|   412k|        .opts = opts,
 3579|   412k|        .opts_cache = opts_cache,
 3580|   412k|        .events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS,
 3581|   412k|        .duration = -1,
 3582|   412k|        .depth = params->depth,
 3583|   412k|    };
 3584|       |
 3585|   412k|    struct demux_internal *in = demuxer->in = talloc_ptrtype(demuxer, in);
  ------------------
  |  |   34|   412k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|   412k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   412k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3586|   412k|    *in = (struct demux_internal){
 3587|   412k|        .global = global,
 3588|   412k|        .log = demuxer->log,
 3589|   412k|        .packet_pool = demux_packet_pool_get(global),
 3590|   412k|        .stats = stats_ctx_create(in, global, "demuxer"),
 3591|   412k|        .can_cache = params->is_top_level,
 3592|   412k|        .can_record = params->stream_record,
 3593|   412k|        .d_thread = talloc(demuxer, struct demuxer),
  ------------------
  |  |   26|   412k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   412k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   412k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3594|   412k|        .d_user = demuxer,
 3595|   412k|        .after_seek = true, // (assumed identical to initial demuxer state)
 3596|   412k|        .after_seek_to_start = true,
 3597|   412k|        .highest_av_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   412k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3598|   412k|        .seeking_in_progress = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   412k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3599|   412k|        .demux_ts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|   412k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3600|   412k|        .owns_stream = !params->external_stream,
 3601|   412k|    };
 3602|   412k|    mp_mutex_init(&in->lock);
 3603|   412k|    mp_cond_init(&in->wakeup);
 3604|       |
 3605|   412k|    *in->d_thread = *demuxer;
 3606|       |
 3607|   412k|    in->d_thread->metadata = talloc_zero(in->d_thread, struct mp_tags);
  ------------------
  |  |   27|   412k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   412k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   412k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3608|       |
 3609|   412k|    in->d_thread->params = params; // temporary during open()
 3610|   412k|    int ret = demuxer->desc->open(in->d_thread, check);
 3611|   412k|    if (ret >= 0) {
  ------------------
  |  Branch (3611:9): [True: 57.5k, False: 354k]
  ------------------
 3612|  57.5k|        in->d_thread->params = NULL;
 3613|  57.5k|        if (in->d_thread->filetype)
  ------------------
  |  Branch (3613:13): [True: 56.9k, False: 551]
  ------------------
 3614|  56.9k|            mp_verbose(log, "Detected file format: %s (%s)\n",
  ------------------
  |  |   79|  56.9k|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3615|  57.5k|                       in->d_thread->filetype, desc->desc);
 3616|    551|        else
 3617|    551|            mp_verbose(log, "Detected file format: %s\n", desc->desc);
  ------------------
  |  |   79|    551|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3618|  57.5k|        if (!in->d_thread->seekable)
  ------------------
  |  Branch (3618:13): [True: 0, False: 57.5k]
  ------------------
 3619|      0|            mp_verbose(log, "Stream is not seekable.\n");
  ------------------
  |  |   79|      0|#define mp_verbose(log, ...)    mp_msg(log, MSGL_V, __VA_ARGS__)
  ------------------
 3620|  57.5k|        if (!in->d_thread->seekable && opts->force_seekable) {
  ------------------
  |  Branch (3620:13): [True: 0, False: 57.5k]
  |  Branch (3620:40): [True: 0, False: 0]
  ------------------
 3621|      0|            mp_warn(log, "Not seekable, but enabling seeking on user request.\n");
  ------------------
  |  |   77|      0|#define mp_warn(log, ...)       mp_msg(log, MSGL_WARN, __VA_ARGS__)
  ------------------
 3622|      0|            in->d_thread->seekable = true;
 3623|      0|            in->d_thread->partially_seekable = true;
 3624|      0|        }
 3625|  57.5k|        demux_init_cuesheet(in->d_thread);
 3626|  57.5k|        demux_init_ccs(demuxer, opts);
 3627|  57.5k|        demux_convert_tags_charset(in->d_thread);
 3628|  57.5k|        demux_copy(in->d_user, in->d_thread);
 3629|  57.5k|        in->duration = in->d_thread->duration;
 3630|  57.5k|        demuxer_sort_chapters(demuxer);
 3631|  57.5k|        in->events = DEMUX_EVENT_INIT | DEMUX_EVENT_DURATION | DEMUX_EVENT_METADATA | DEMUX_EVENT_STREAMS;
 3632|       |
 3633|  57.5k|        struct demuxer *sub = NULL;
 3634|  57.5k|        if (!params->disable_timeline) {
  ------------------
  |  Branch (3634:13): [True: 57.5k, False: 0]
  ------------------
 3635|  57.5k|            struct timeline *tl = timeline_load(global, log, demuxer);
 3636|  57.5k|            if (tl) {
  ------------------
  |  Branch (3636:17): [True: 0, False: 57.5k]
  ------------------
 3637|      0|                struct demuxer_params params2 = {0};
 3638|      0|                params2.timeline = tl;
 3639|      0|                params2.is_top_level = params->is_top_level;
 3640|      0|                params2.stream_record = params->stream_record;
 3641|      0|                params2.depth = params->depth + 1;
 3642|      0|                sub =
 3643|      0|                    open_given_type(global, log, &demuxer_desc_timeline,
 3644|      0|                                    NULL, sinfo, &params2, DEMUX_CHECK_FORCE);
 3645|      0|                if (sub) {
  ------------------
  |  Branch (3645:21): [True: 0, False: 0]
  ------------------
 3646|      0|                    in->can_cache = false;
 3647|      0|                    in->can_record = false;
 3648|      0|                } else {
 3649|      0|                    timeline_destroy(tl);
 3650|      0|                }
 3651|      0|            }
 3652|  57.5k|        }
 3653|       |
 3654|  57.5k|        switch_to_fresh_cache_range(in);
 3655|       |
 3656|  57.5k|        update_opts(demuxer);
 3657|       |
 3658|  57.5k|        demux_update(demuxer, MP_NOPTS_VALUE);
  ------------------
  |  |   39|  57.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 3659|       |
 3660|  57.5k|        demuxer = sub ? sub : demuxer;
  ------------------
  |  Branch (3660:19): [True: 0, False: 57.5k]
  ------------------
 3661|  57.5k|        return demuxer;
 3662|  57.5k|    }
 3663|       |
 3664|   354k|    demuxer->stream = NULL;
 3665|   354k|    demux_free(demuxer);
 3666|       |    return NULL;
 3667|   412k|}
demux.c:demux_init_cuesheet:
 3450|  57.5k|{
 3451|  57.5k|    if (demuxer->num_chapters)
  ------------------
  |  Branch (3451:9): [True: 0, False: 57.5k]
  ------------------
 3452|      0|        return;
 3453|       |
 3454|  57.5k|    struct sh_stream *sh = demuxer->in->metadata_stream;
 3455|  57.5k|    char *cue = mp_tags_get_str(demuxer->metadata, "cuesheet");
 3456|  57.5k|    if (!cue && sh)
  ------------------
  |  Branch (3456:9): [True: 57.5k, False: 0]
  |  Branch (3456:17): [True: 57.0k, False: 451]
  ------------------
 3457|  57.0k|        cue = mp_tags_get_str(sh->tags, "cuesheet");
 3458|  57.5k|    if (!cue)
  ------------------
  |  Branch (3458:9): [True: 57.5k, False: 0]
  ------------------
 3459|  57.5k|        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|  57.5k|{
 3499|  57.5k|    struct demux_internal *in = demuxer->in;
 3500|  57.5k|    if (!opts->create_ccs)
  ------------------
  |  Branch (3500:9): [True: 57.5k, False: 0]
  ------------------
 3501|  57.5k|        return;
 3502|      0|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 3503|      0|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3503:21): [True: 0, False: 0]
  ------------------
 3504|      0|        struct sh_stream *sh = in->streams[n];
 3505|      0|        if (sh->type == STREAM_VIDEO && !sh->attached_picture)
  ------------------
  |  Branch (3505:13): [True: 0, False: 0]
  |  Branch (3505:41): [True: 0, False: 0]
  ------------------
 3506|      0|            demuxer_get_cc_track_locked(sh);
 3507|      0|    }
 3508|      0|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 3509|      0|}
demux.c:demux_convert_tags_charset:
 5041|  57.5k|{
 5042|  57.5k|    struct demux_internal *in = demuxer->in;
 5043|       |
 5044|  57.5k|    char *cp = demuxer->opts->meta_cp;
 5045|  57.5k|    if (!cp || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (5045:9): [True: 0, False: 57.5k]
  |  Branch (5045:16): [True: 0, False: 57.5k]
  ------------------
 5046|      0|        return;
 5047|       |
 5048|  57.5k|    char *data = talloc_strdup(NULL, "");
  ------------------
  |  |   50|  57.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 5049|  57.5k|    visit_meta(demuxer, &data, visit_detect);
 5050|       |
 5051|  57.5k|    in->meta_charset = (char *)mp_charset_guess(in, in->log, bstr0(data), cp, 0);
 5052|  57.5k|    if (in->meta_charset && !mp_charset_is_utf8(in->meta_charset)) {
  ------------------
  |  Branch (5052:9): [True: 57.5k, False: 0]
  |  Branch (5052:29): [True: 269, False: 57.2k]
  ------------------
 5053|    269|        MP_INFO(demuxer, "Using tag charset: %s\n", in->meta_charset);
  ------------------
  |  |   91|    269|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    269|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 5054|    269|        visit_meta(demuxer, demuxer, visit_convert);
 5055|    269|    }
 5056|       |
 5057|  57.5k|    talloc_free(data);
  ------------------
  |  |   47|  57.5k|#define talloc_free                     ta_free
  ------------------
 5058|  57.5k|}
demux.c:visit_meta:
 4995|  57.7k|{
 4996|  57.7k|    struct demux_internal *in = demuxer->in;
 4997|       |
 4998|   140k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4998:21): [True: 82.5k, False: 57.7k]
  ------------------
 4999|  82.5k|        struct sh_stream *sh = in->streams[n];
 5000|       |
 5001|  82.5k|        visit(ctx, sh, &sh->title);
 5002|  82.5k|        visit_tags(ctx, visit, sh->tags);
 5003|  82.5k|    }
 5004|       |
 5005|  57.7k|    for (int n = 0; n < demuxer->num_chapters; n++)
  ------------------
  |  Branch (5005:21): [True: 0, False: 57.7k]
  ------------------
 5006|      0|        visit_tags(ctx, visit, demuxer->chapters[n].metadata);
 5007|       |
 5008|  57.7k|    visit_tags(ctx, visit, demuxer->metadata);
 5009|  57.7k|}
demux.c:visit_tags:
 4988|   140k|{
 4989|   170k|    for (int n = 0; n < (tags ? tags->num_keys : 0); n++)
  ------------------
  |  Branch (4989:21): [True: 29.7k, False: 140k]
  |  Branch (4989:26): [True: 170k, False: 0]
  ------------------
 4990|  29.7k|        visit(ctx, tags, &tags->values[n]);
 4991|   140k|}
demux.c:visit_detect:
 5013|   106k|{
 5014|   106k|    char **all = ctx;
 5015|       |
 5016|   106k|    if (*s)
  ------------------
  |  Branch (5016:9): [True: 25.8k, False: 80.5k]
  ------------------
 5017|  25.8k|        *all = talloc_asprintf_append_buffer(*all, "%s\n", *s);
  ------------------
  |  |   64|  25.8k|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
 5018|   106k|}
demux.c:visit_convert:
 5021|  5.91k|{
 5022|  5.91k|    struct demuxer *demuxer = ctx;
 5023|  5.91k|    struct demux_internal *in = demuxer->in;
 5024|       |
 5025|  5.91k|    if (!*s)
  ------------------
  |  Branch (5025:9): [True: 1.95k, False: 3.96k]
  ------------------
 5026|  1.95k|        return;
 5027|       |
 5028|  3.96k|    bstr data = bstr0(*s);
 5029|  3.96k|    bstr conv = mp_iconv_to_utf8(in->log, data, in->meta_charset,
 5030|  3.96k|                                 MP_ICONV_VERBOSE);
 5031|  3.96k|    if (conv.start && conv.start != data.start) {
  ------------------
  |  Branch (5031:9): [True: 3.96k, False: 0]
  |  Branch (5031:23): [True: 2.41k, False: 1.54k]
  ------------------
 5032|  2.41k|        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|  2.41k|        *s = ns;
 5036|  2.41k|        talloc_steal(ta, *s);
  ------------------
  |  |   38|  2.41k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.41k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 5037|  2.41k|    }
 5038|  3.96k|}
demux.c:demux_copy:
 3183|  57.5k|{
 3184|       |    // Note that we do as shallow copies as possible. We expect the data
 3185|       |    // that is not-copied (only referenced) to be immutable.
 3186|       |    // This implies e.g. that no chapters are added after initialization.
 3187|  57.5k|    dst->chapters = src->chapters;
 3188|  57.5k|    dst->num_chapters = src->num_chapters;
 3189|  57.5k|    dst->editions = src->editions;
 3190|  57.5k|    dst->num_editions = src->num_editions;
 3191|  57.5k|    dst->edition = src->edition;
 3192|  57.5k|    dst->edition_is_track_mapping = src->edition_is_track_mapping;
 3193|  57.5k|    dst->attachments = src->attachments;
 3194|  57.5k|    dst->num_attachments = src->num_attachments;
 3195|  57.5k|    dst->matroska_data = src->matroska_data;
 3196|  57.5k|    dst->playlist = src->playlist;
 3197|  57.5k|    dst->seekable = src->seekable;
 3198|  57.5k|    dst->partially_seekable = src->partially_seekable;
 3199|  57.5k|    dst->filetype = src->filetype;
 3200|  57.5k|    dst->ts_resets_possible = src->ts_resets_possible;
 3201|  57.5k|    dst->fully_read = src->fully_read;
 3202|  57.5k|    dst->start_time = src->start_time;
 3203|  57.5k|    dst->duration = src->duration;
 3204|  57.5k|    dst->is_network = src->is_network;
 3205|  57.5k|    dst->is_streaming = src->is_streaming;
 3206|  57.5k|    dst->stream_origin = src->stream_origin;
 3207|  57.5k|    dst->priv = src->priv;
 3208|  57.5k|    dst->metadata = mp_tags_dup(dst, src->metadata);
 3209|  57.5k|}
demux.c:demuxer_sort_chapters:
 4465|  57.5k|{
 4466|  57.5k|    if (demuxer->num_chapters) {
  ------------------
  |  Branch (4466:9): [True: 0, False: 57.5k]
  ------------------
 4467|      0|        qsort(demuxer->chapters, demuxer->num_chapters,
 4468|      0|            sizeof(struct demux_chapter), chapter_compare);
 4469|      0|    }
 4470|  57.5k|}
demux.c:switch_to_fresh_cache_range:
 4058|  59.8k|{
 4059|  59.8k|    if (!in->seekable_cache && in->current_range) {
  ------------------
  |  Branch (4059:9): [True: 59.8k, False: 0]
  |  Branch (4059:32): [True: 2.34k, False: 57.5k]
  ------------------
 4060|  2.34k|        clear_cached_range(in, in->current_range);
 4061|  2.34k|        return;
 4062|  2.34k|    }
 4063|       |
 4064|  57.5k|    struct demux_cached_range *range = talloc_ptrtype(NULL, range);
  ------------------
  |  |   34|  57.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  57.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4065|  57.5k|    *range = (struct demux_cached_range){
 4066|  57.5k|        .seek_start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  57.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4067|  57.5k|        .seek_end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  57.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 4068|  57.5k|    };
 4069|  57.5k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|  57.5k|    do {                                            \
  |  |  106|  57.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  57.5k|    do {                                            \
  |  |  |  |   97|  57.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  57.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  57.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  57.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 57.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  57.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  57.5k|    do {                                                        \
  |  |  |  |  |  |   89|  57.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  57.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  57.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  57.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  57.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  57.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  57.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 57.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  57.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 57.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  57.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  57.5k|        (idxvar)++;                                 \
  |  |  109|  57.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 57.5k]
  |  |  ------------------
  ------------------
 4070|  57.5k|    add_missing_streams(in, range);
 4071|       |
 4072|  57.5k|    switch_current_range(in, range);
 4073|  57.5k|}
demux.c:switch_current_range:
 3822|  57.5k|{
 3823|  57.5k|    struct demux_cached_range *old = in->current_range;
 3824|  57.5k|    mp_assert(old != range);
  ------------------
  |  |   41|  57.5k|#define mp_assert assert
  ------------------
  |  Branch (3824:5): [True: 57.5k, False: 0]
  ------------------
 3825|       |
 3826|  57.5k|    set_current_range(in, range);
 3827|       |
 3828|  57.5k|    if (old) {
  ------------------
  |  Branch (3828:9): [True: 0, False: 57.5k]
  ------------------
 3829|       |        // Remove packets which can't be used when seeking back to the range.
 3830|      0|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3830:25): [True: 0, False: 0]
  ------------------
 3831|      0|            struct demux_queue *queue = old->streams[n];
 3832|       |
 3833|       |            // Remove all packets which cannot be involved in seeking.
 3834|      0|            while (queue->head && !queue->head->keyframe)
  ------------------
  |  Branch (3834:20): [True: 0, False: 0]
  |  Branch (3834:35): [True: 0, False: 0]
  ------------------
 3835|      0|                remove_head_packet(queue);
 3836|      0|        }
 3837|       |
 3838|       |        // Exclude weird corner cases that break resuming.
 3839|      0|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3839:25): [True: 0, False: 0]
  ------------------
 3840|      0|            struct demux_stream *ds = in->streams[n]->ds;
 3841|       |            // This is needed to resume or join the range at all.
 3842|      0|            if (ds->selected && !(ds->global_correct_dts ||
  ------------------
  |  Branch (3842:17): [True: 0, False: 0]
  |  Branch (3842:35): [True: 0, False: 0]
  ------------------
 3843|      0|                                  ds->global_correct_pos))
  ------------------
  |  Branch (3843:35): [True: 0, False: 0]
  ------------------
 3844|      0|            {
 3845|      0|                MP_VERBOSE(in, "discarding unseekable range due to stream %d\n", n);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3846|      0|                clear_cached_range(in, old);
 3847|      0|                break;
 3848|      0|            }
 3849|      0|        }
 3850|      0|    }
 3851|       |
 3852|       |    // Set up reading from new range (as well as writing to it).
 3853|   138k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (3853:21): [True: 80.6k, False: 57.5k]
  ------------------
 3854|  80.6k|        struct demux_stream *ds = in->streams[n]->ds;
 3855|       |
 3856|  80.6k|        ds->queue = range->streams[n];
 3857|  80.6k|        ds->refreshing = false;
 3858|  80.6k|        ds->eof = false;
 3859|  80.6k|    }
 3860|       |
 3861|       |    // No point in keeping any junk (especially if old current_range is empty).
 3862|  57.5k|    free_empty_cached_ranges(in);
 3863|       |
 3864|       |    // The change detection doesn't work across ranges.
 3865|       |    in->force_metadata_update = true;
 3866|  57.5k|}
demux.c:set_current_range:
  589|  57.5k|{
  590|  57.5k|    in->current_range = range;
  591|       |
  592|       |    // Move to in->ranges[in->num_ranges-1] (for LRU sorting/invariant)
  593|  57.5k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (593:21): [True: 57.5k, False: 0]
  ------------------
  594|  57.5k|        if (in->ranges[n] == range) {
  ------------------
  |  Branch (594:13): [True: 57.5k, False: 0]
  ------------------
  595|  57.5k|            MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|  57.5k|    do {                                            \
  |  |  144|  57.5k|        size_t at_ = (at);                          \
  |  |  145|  57.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  57.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  57.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  57.5k|        (idxvar)--;                                 \
  |  |  149|  57.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 57.5k]
  |  |  ------------------
  ------------------
  |  Branch (595:13): [True: 57.5k, False: 0]
  ------------------
  596|  57.5k|            break;
  597|  57.5k|        }
  598|  57.5k|    }
  599|  57.5k|    MP_TARRAY_APPEND(in, in->ranges, in->num_ranges, range);
  ------------------
  |  |  105|  57.5k|    do {                                            \
  |  |  106|  57.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  57.5k|    do {                                            \
  |  |  |  |   97|  57.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  57.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  57.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  57.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 57.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  57.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|  57.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 57.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  57.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  57.5k|        (idxvar)++;                                 \
  |  |  109|  57.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 57.5k]
  |  |  ------------------
  ------------------
  600|  57.5k|}
demux.c:clear_reader_state:
  874|   414k|{
  875|   497k|    for (int n = 0; n < in->num_streams; n++)
  ------------------
  |  Branch (875:21): [True: 83.0k, False: 414k]
  ------------------
  876|  83.0k|        ds_clear_reader_state(in->streams[n]->ds, clear_back_state);
  877|   414k|    in->warned_queue_overflow = false;
  878|   414k|    in->d_user->filepos = -1; // implicitly synchronized
  879|   414k|    in->blocked = false;
  880|       |    in->need_back_seek = false;
  881|   414k|}
demux.c:clear_cached_range:
  784|   117k|{
  785|   281k|    for (int n = 0; n < range->num_streams; n++)
  ------------------
  |  Branch (785:21): [True: 163k, False: 117k]
  ------------------
  786|   163k|        clear_queue(range->streams[n]);
  787|       |
  788|   117k|    for (int n = 0; n < range->num_metadata; n++)
  ------------------
  |  Branch (788:21): [True: 0, False: 117k]
  ------------------
  789|      0|        talloc_free(range->metadata[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  790|   117k|    range->num_metadata = 0;
  791|       |
  792|   117k|    update_seek_ranges(range);
  793|   117k|}
demux.c:free_empty_cached_ranges:
  798|  1.05M|{
  799|  1.05M|    while (1) {
  ------------------
  |  Branch (799:12): [True: 1.05M, Folded]
  ------------------
  800|  1.05M|        struct demux_cached_range *worst = NULL;
  801|       |
  802|  1.05M|        int end = in->num_ranges - 1;
  803|       |
  804|       |        // (Not set during early init or late destruction.)
  805|  1.05M|        if (in->current_range) {
  ------------------
  |  Branch (805:13): [True: 211k, False: 847k]
  ------------------
  806|   211k|            mp_assert(in->current_range && in->num_ranges > 0);
  ------------------
  |  |   41|   211k|#define mp_assert assert
  ------------------
  |  Branch (806:13): [True: 211k, False: 0]
  |  Branch (806:13): [True: 211k, False: 0]
  ------------------
  807|   211k|            mp_assert(in->current_range == in->ranges[in->num_ranges - 1]);
  ------------------
  |  |   41|   211k|#define mp_assert assert
  ------------------
  |  Branch (807:13): [True: 211k, False: 0]
  ------------------
  808|   211k|            end -= 1;
  809|   211k|        }
  810|       |
  811|  1.11M|        for (int n = end; n >= 0; n--) {
  ------------------
  |  Branch (811:27): [True: 57.5k, False: 1.05M]
  ------------------
  812|  57.5k|            struct demux_cached_range *range = in->ranges[n];
  813|  57.5k|            if (range->seek_start == MP_NOPTS_VALUE || !in->seekable_cache) {
  ------------------
  |  |   39|   115k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (813:17): [True: 57.5k, False: 0]
  |  Branch (813:56): [True: 0, False: 0]
  ------------------
  814|  57.5k|                clear_cached_range(in, range);
  815|  57.5k|                MP_TARRAY_REMOVE_AT(in->ranges, in->num_ranges, n);
  ------------------
  |  |  143|  57.5k|    do {                                            \
  |  |  144|  57.5k|        size_t at_ = (at);                          \
  |  |  145|  57.5k|        assert(at_ < (idxvar));                     \
  |  |  146|  57.5k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  57.5k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  57.5k|        (idxvar)--;                                 \
  |  |  149|  57.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 57.5k]
  |  |  ------------------
  ------------------
  |  Branch (815:17): [True: 57.5k, False: 0]
  ------------------
  816|   138k|                for (int i = 0; i < range->num_streams; i++)
  ------------------
  |  Branch (816:33): [True: 80.6k, False: 57.5k]
  ------------------
  817|  80.6k|                    talloc_free(range->streams[i]);
  ------------------
  |  |   47|  80.6k|#define talloc_free                     ta_free
  ------------------
  818|  57.5k|                talloc_free(range);
  ------------------
  |  |   47|  57.5k|#define talloc_free                     ta_free
  ------------------
  819|  57.5k|            } else {
  820|      0|                if (!worst || (range->seek_end - range->seek_start <
  ------------------
  |  Branch (820:21): [True: 0, False: 0]
  |  Branch (820:31): [True: 0, False: 0]
  ------------------
  821|      0|                               worst->seek_end - worst->seek_start))
  822|      0|                    worst = range;
  823|      0|            }
  824|  57.5k|        }
  825|       |
  826|  1.05M|        if (in->num_ranges <= MAX_SEEK_RANGES || !worst)
  ------------------
  |  |   33|  2.11M|#define MAX_SEEK_RANGES 10
  ------------------
  |  Branch (826:13): [True: 1.05M, False: 0]
  |  Branch (826:50): [True: 0, False: 0]
  ------------------
  827|  1.05M|            break;
  828|       |
  829|      0|        clear_cached_range(in, worst);
  830|      0|    }
  831|  1.05M|}
demux.c:queue_seek:
 4095|  2.34k|{
 4096|  2.34k|    if (seek_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|  2.34k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4096:9): [True: 0, False: 2.34k]
  ------------------
 4097|      0|        return false;
 4098|       |
 4099|  2.34k|    MP_VERBOSE(in, "queuing seek to %f%s\n", seek_pts,
  ------------------
  |  |   92|  2.34k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.69k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 2.34k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4100|  2.34k|               in->seeking ? " (cascade)" : "");
 4101|       |
 4102|  2.34k|    bool require_cache = flags & SEEK_CACHED;
  ------------------
  |  |   97|  2.34k|#define SEEK_CACHED   (1 << 3)      // allow packet cache seeks only
  ------------------
 4103|  2.34k|    flags &= ~(unsigned)SEEK_CACHED;
  ------------------
  |  |   97|  2.34k|#define SEEK_CACHED   (1 << 3)      // allow packet cache seeks only
  ------------------
 4104|       |
 4105|  2.34k|    bool set_backwards = flags & SEEK_SATAN;
  ------------------
  |  |   98|  2.34k|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
 4106|  2.34k|    flags &= ~(unsigned)SEEK_SATAN;
  ------------------
  |  |   98|  2.34k|#define SEEK_SATAN    (1 << 4)      // enable backward demuxing
  ------------------
 4107|       |
 4108|  2.34k|    bool block = flags & SEEK_BLOCK;
  ------------------
  |  |  100|  2.34k|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
 4109|  2.34k|    flags &= ~(unsigned)SEEK_BLOCK;
  ------------------
  |  |  100|  2.34k|#define SEEK_BLOCK    (1 << 6)      // upon successfully queued seek, block readers
  ------------------
 4110|       |
 4111|  2.34k|    struct demux_cached_range *cache_target =
 4112|  2.34k|        find_cache_seek_range(in, seek_pts, flags);
 4113|       |
 4114|  2.34k|    if (!cache_target) {
  ------------------
  |  Branch (4114:9): [True: 2.34k, False: 0]
  ------------------
 4115|  2.34k|        if (require_cache) {
  ------------------
  |  Branch (4115:13): [True: 0, False: 2.34k]
  ------------------
 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|  2.34k|        if (!in->d_thread->seekable) {
  ------------------
  |  Branch (4119:13): [True: 0, False: 2.34k]
  ------------------
 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|  2.34k|    }
 4124|       |
 4125|  2.34k|    in->eof = false;
 4126|  2.34k|    in->reading = false;
 4127|  2.34k|    in->back_demuxing = set_backwards;
 4128|       |
 4129|  2.34k|    clear_reader_state(in, clear_back_state);
 4130|       |
 4131|  2.34k|    in->blocked = block;
 4132|       |
 4133|  2.34k|    if (cache_target) {
  ------------------
  |  Branch (4133:9): [True: 0, False: 2.34k]
  ------------------
 4134|      0|        execute_cache_seek(in, cache_target, seek_pts, flags);
 4135|  2.34k|    } else {
 4136|  2.34k|        switch_to_fresh_cache_range(in);
 4137|       |
 4138|  2.34k|        in->seeking = true;
 4139|  2.34k|        in->seek_flags = flags;
 4140|  2.34k|        in->seek_pts = seek_pts;
 4141|  2.34k|    }
 4142|       |
 4143|  4.69k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4143:21): [True: 2.34k, False: 2.34k]
  ------------------
 4144|  2.34k|        struct demux_stream *ds = in->streams[n]->ds;
 4145|       |
 4146|  2.34k|        if (in->back_demuxing) {
  ------------------
  |  Branch (4146:13): [True: 0, False: 2.34k]
  ------------------
 4147|      0|            if (ds->back_seek_pos == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4147:17): [True: 0, False: 0]
  ------------------
 4148|      0|                ds->back_seek_pos = seek_pts;
 4149|       |            // Process possibly cached packets.
 4150|      0|            back_demux_see_packets(in->streams[n]->ds);
 4151|      0|        }
 4152|       |
 4153|  2.34k|        wakeup_ds(ds);
 4154|  2.34k|    }
 4155|       |
 4156|  2.34k|    if (!in->threading && in->seeking)
  ------------------
  |  Branch (4156:9): [True: 2.34k, False: 0]
  |  Branch (4156:27): [True: 2.34k, False: 0]
  ------------------
 4157|  2.34k|        execute_seek(in);
 4158|       |
 4159|       |    return true;
 4160|  2.34k|}
demux.c:select_track:
 4290|  39.5k|{
 4291|  39.5k|    struct demux_stream *ds = stream->ds;
 4292|  39.5k|    if (ds->selected == selected)
  ------------------
  |  Branch (4292:9): [True: 340, False: 39.2k]
  ------------------
 4293|    340|        return false;
 4294|  39.2k|    MP_VERBOSE(in, "%sselect track %d\n", selected ? "" : "de", stream->index);
  ------------------
  |  |   92|  39.2k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  78.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 39.2k, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4295|  39.2k|    ds->selected = selected;
 4296|  39.2k|    update_stream_selection_state(in, ds);
 4297|  39.2k|    in->tracks_switched = true;
 4298|  39.2k|    if (ds->selected)
  ------------------
  |  Branch (4298:9): [True: 39.2k, False: 25]
  ------------------
 4299|  39.2k|        refresh_track(in, stream, ref_pts);
 4300|       |    return true;
 4301|  39.5k|}
demux.c:select_dependent_tracks:
 4307|  39.5k|{
 4308|  39.5k|    bool changed = false;
 4309|  39.5k|    if (stream->group && !stream->dependent_track) {
  ------------------
  |  Branch (4309:9): [True: 0, False: 39.5k]
  |  Branch (4309:26): [True: 0, False: 0]
  ------------------
 4310|      0|        for (int i = 0; i < stream->group->num_members; i++) {
  ------------------
  |  Branch (4310:25): [True: 0, False: 0]
  ------------------
 4311|      0|            struct sh_stream *m = stream->group->members[i];
 4312|      0|            mp_assert(m);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (4312:13): [True: 0, False: 0]
  ------------------
 4313|      0|            if (m != stream && m->dependent_track)
  ------------------
  |  Branch (4313:17): [True: 0, False: 0]
  |  Branch (4313:32): [True: 0, False: 0]
  ------------------
 4314|      0|                changed |= select_track(in, m, ref_pts, selected);
 4315|      0|        }
 4316|      0|    }
 4317|  39.5k|    return changed;
 4318|  39.5k|}
demux.c:execute_trackswitch:
 2580|  39.2k|{
 2581|  39.2k|    in->tracks_switched = false;
 2582|       |
 2583|  39.2k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|  39.2k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 2584|       |
 2585|  39.2k|    if (in->d_thread->desc->switched_tracks)
  ------------------
  |  Branch (2585:9): [True: 39.2k, False: 18.4E]
  ------------------
 2586|  39.2k|        in->d_thread->desc->switched_tracks(in->d_thread);
 2587|       |
 2588|  39.2k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|  39.2k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 2589|  39.2k|}
demux.c:update_stream_selection_state:
  948|   119k|{
  949|   119k|    ds->eof = false;
  950|   119k|    ds->refreshing = false;
  951|       |
  952|   119k|    update_stream_eager_state(in);
  953|       |
  954|   119k|    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|   159k|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (960:21): [True: 39.2k, False: 119k]
  ------------------
  961|  39.2k|        struct demux_cached_range *range = in->ranges[n];
  962|       |
  963|  39.2k|        if (!ds->selected)
  ------------------
  |  Branch (963:13): [True: 90, False: 39.2k]
  ------------------
  964|     90|            clear_queue(range->streams[ds->index]);
  965|       |
  966|  39.2k|        update_seek_ranges(range);
  967|  39.2k|    }
  968|       |
  969|   119k|    free_empty_cached_ranges(in);
  970|       |
  971|   119k|    wakeup_ds(ds);
  972|   119k|}
demux.c:refresh_track:
 4256|  39.2k|{
 4257|  39.2k|    struct demux_stream *ds = stream->ds;
 4258|  39.2k|    ref_pts = MP_ADD_PTS(ref_pts, -in->ts_offset);
  ------------------
  |  |   67|  39.2k|#define MP_ADD_PTS(a, b) ((a) == MP_NOPTS_VALUE ? (a) : ((a) + (b)))
  |  |  ------------------
  |  |  |  |   39|  39.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (67:27): [True: 0, False: 39.2k]
  |  |  ------------------
  ------------------
 4259|       |
 4260|  39.2k|    if (in->back_demuxing)
  ------------------
  |  Branch (4260:9): [True: 0, False: 39.2k]
  ------------------
 4261|      0|        ds->back_seek_pos = ref_pts;
 4262|       |    // Avoid refresh seek for video streams except when immediately after a seek
 4263|       |    // to ensure a correct seek position.
 4264|  39.2k|    bool avoid_refresh = false;
 4265|  46.2k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4265:21): [True: 39.5k, False: 6.68k]
  ------------------
 4266|  39.5k|        struct demux_stream *ds_n = in->streams[n]->ds;
 4267|  39.5k|        if (ds_n->type == STREAM_VIDEO && ds_n->selected) {
  ------------------
  |  Branch (4267:13): [True: 32.6k, False: 6.92k]
  |  Branch (4267:43): [True: 32.5k, False: 134]
  ------------------
 4268|  32.5k|            avoid_refresh = true;
 4269|  32.5k|            break;
 4270|  32.5k|        }
 4271|  39.5k|    }
 4272|  39.2k|    avoid_refresh = avoid_refresh && !(in->after_seek && !in->after_seek_to_start);
  ------------------
  |  Branch (4272:21): [True: 32.5k, False: 6.68k]
  |  Branch (4272:40): [True: 32.5k, False: 0]
  |  Branch (4272:58): [True: 0, False: 32.5k]
  ------------------
 4273|       |    // Allow refresh seek for non-video streams, even if no packets have
 4274|       |    // ever been read yet or after seeking. This is necessary because:
 4275|       |    // - A-V sync targets may come from different demuxers, so enabling an external
 4276|       |    //   audio track for the first time can cause desync since a seek is not performed.
 4277|       |    // - If cache is enabled and a seek causes some new data to be cached, the demuxer
 4278|       |    //   is sought to the end of cache after cache joining. Switching track immediately
 4279|       |    //   after this also causes the same problem.
 4280|  39.2k|    if (!in->after_seek || (ds->type != STREAM_VIDEO && !avoid_refresh)) {
  ------------------
  |  Branch (4280:9): [True: 0, False: 39.2k]
  |  Branch (4280:29): [True: 6.68k, False: 32.5k]
  |  Branch (4280:57): [True: 6.68k, False: 0]
  ------------------
 4281|  6.68k|        MP_VERBOSE(in, "refresh track %d (%s)\n", stream->index,
  ------------------
  |  |   92|  6.68k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.68k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4282|  6.68k|                   stream_type_name(ds->type));
 4283|  6.68k|        initiate_refresh_seek(in, ds, ref_pts);
 4284|  6.68k|    }
 4285|  39.2k|}
demux.c:initiate_refresh_seek:
 4184|  6.68k|{
 4185|  6.68k|    struct demuxer *demux = in->d_thread;
 4186|  6.68k|    bool seekable = demux->desc->seek && demux->seekable &&
  ------------------
  |  Branch (4186:21): [True: 6.68k, False: 0]
  |  Branch (4186:42): [True: 6.68k, False: 0]
  ------------------
 4187|  6.68k|                    !demux->partially_seekable;
  ------------------
  |  Branch (4187:21): [True: 6.68k, False: 0]
  ------------------
 4188|       |
 4189|  6.68k|    bool normal_seek = true;
 4190|  6.68k|    bool refresh_possible = true;
 4191|  13.7k|    for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4191:21): [True: 7.05k, False: 6.68k]
  ------------------
 4192|  7.05k|        struct demux_stream *ds = in->streams[n]->ds;
 4193|       |
 4194|  7.05k|        if (!ds->selected)
  ------------------
  |  Branch (4194:13): [True: 369, False: 6.68k]
  ------------------
 4195|    369|            continue;
 4196|       |
 4197|  6.68k|        if (ds->type == STREAM_VIDEO || ds->type == STREAM_AUDIO)
  ------------------
  |  Branch (4197:13): [True: 0, False: 6.68k]
  |  Branch (4197:41): [True: 0, False: 6.68k]
  ------------------
 4198|      0|            start_ts = MP_PTS_MIN(start_ts, ds->base_ts);
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4199|       |
 4200|       |        // If there were no other streams selected, we can use a normal seek.
 4201|  6.68k|        normal_seek &= stream == ds;
 4202|       |
 4203|  6.68k|        refresh_possible &= ds->queue->correct_dts || ds->queue->correct_pos;
  ------------------
  |  Branch (4203:29): [True: 6.68k, False: 0]
  |  Branch (4203:55): [True: 0, False: 0]
  ------------------
 4204|  6.68k|    }
 4205|       |
 4206|  6.68k|    if (start_ts == MP_NOPTS_VALUE || !seekable)
  ------------------
  |  |   39|  13.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4206:9): [True: 0, False: 6.68k]
  |  Branch (4206:39): [True: 0, False: 6.68k]
  ------------------
 4207|      0|        return;
 4208|       |
 4209|  6.68k|    if (!normal_seek) {
  ------------------
  |  Branch (4209:9): [True: 0, False: 6.68k]
  ------------------
 4210|      0|        if (!refresh_possible) {
  ------------------
  |  Branch (4210:13): [True: 0, False: 0]
  ------------------
 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|      0|        for (int n = 0; n < in->num_streams; n++) {
  ------------------
  |  Branch (4215:25): [True: 0, False: 0]
  ------------------
 4216|      0|            struct demux_stream *ds = in->streams[n]->ds;
 4217|       |
 4218|      0|            bool correct_pos = ds->queue->correct_pos;
 4219|      0|            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|      0|            ds_clear_reader_queue_state(ds);
 4227|      0|            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|      0|            if (ds->selected && (ds->last_ret_pos != -1 ||
  ------------------
  |  Branch (4231:17): [True: 0, False: 0]
  |  Branch (4231:34): [True: 0, False: 0]
  ------------------
 4232|      0|                                 ds->last_ret_dts != MP_NOPTS_VALUE))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (4232:34): [True: 0, False: 0]
  ------------------
 4233|      0|            {
 4234|      0|                ds->refreshing = true;
 4235|      0|                ds->queue->correct_dts = correct_dts;
 4236|      0|                ds->queue->correct_pos = correct_pos;
 4237|      0|                ds->queue->last_pos = ds->last_ret_pos;
 4238|      0|                ds->queue->last_dts = ds->last_ret_dts;
 4239|      0|            }
 4240|       |
 4241|      0|            update_seek_ranges(in->current_range);
 4242|      0|        }
 4243|       |
 4244|      0|        start_ts -= 1.0; // small offset to get correct overlap
 4245|      0|    }
 4246|       |
 4247|  6.68k|    MP_VERBOSE(in, "refresh seek to %f\n", start_ts);
  ------------------
  |  |   92|  6.68k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  6.68k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 4248|  6.68k|    in->seeking = true;
 4249|  6.68k|    in->seek_flags = SEEK_HR;
  ------------------
  |  |   99|  6.68k|#define SEEK_HR       (1 << 5)      // hr-seek (this is a weak hint only)
  ------------------
 4250|  6.68k|    in->seek_pts = start_ts;
 4251|  6.68k|}
demux.c:wakeup_ds:
  887|  1.03M|{
  888|  1.03M|    if (ds->need_wakeup) {
  ------------------
  |  Branch (888:9): [True: 172k, False: 864k]
  ------------------
  889|   172k|        if (ds->wakeup_cb) {
  ------------------
  |  Branch (889:13): [True: 44.9k, False: 127k]
  ------------------
  890|  44.9k|            ds->wakeup_cb(ds->wakeup_cb_ctx);
  891|   127k|        } else if (ds->in->wakeup_cb) {
  ------------------
  |  Branch (891:20): [True: 42.5k, False: 85.3k]
  ------------------
  892|  42.5k|            ds->in->wakeup_cb(ds->in->wakeup_cb_ctx);
  893|  42.5k|        }
  894|       |        ds->need_wakeup = false;
  895|   172k|        mp_cond_signal(&ds->in->wakeup);
  896|   172k|    }
  897|  1.03M|}
demux.c:update_cache:
 4528|   973k|{
 4529|   973k|    struct demuxer *demuxer = in->d_thread;
 4530|   973k|    struct stream *stream = demuxer->stream;
 4531|       |
 4532|   973k|    int64_t now = mp_time_ns();
 4533|   973k|    int64_t diff = now - in->last_speed_query;
 4534|   973k|    bool do_update = diff >= MP_TIME_S_TO_NS(1) || !in->last_speed_query;
  ------------------
  |  |   71|  1.94M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (4534:22): [True: 57.4k, False: 915k]
  |  Branch (4534:52): [True: 59, False: 915k]
  ------------------
 4535|       |
 4536|       |    // Don't lock while querying the stream.
 4537|   973k|    mp_mutex_unlock(&in->lock);
  ------------------
  |  |  136|   973k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 4538|       |
 4539|   973k|    int64_t stream_size = -1;
 4540|   973k|    struct mp_tags *stream_metadata = NULL;
 4541|   973k|    if (stream) {
  ------------------
  |  Branch (4541:9): [True: 958k, False: 14.8k]
  ------------------
 4542|   958k|        if (do_update)
  ------------------
  |  Branch (4542:13): [True: 55.1k, False: 903k]
  ------------------
 4543|  55.1k|            stream_size = stream_get_size(stream);
 4544|   958k|        stream_control(stream, STREAM_CTRL_GET_METADATA, &stream_metadata);
 4545|   958k|    }
 4546|       |
 4547|   973k|    mp_mutex_lock(&in->lock);
  ------------------
  |  |  134|   973k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 4548|       |
 4549|   973k|    update_bytes_read(in);
 4550|       |
 4551|   973k|    if (do_update)
  ------------------
  |  Branch (4551:9): [True: 57.5k, False: 915k]
  ------------------
 4552|  57.5k|        in->stream_size = stream_size;
 4553|   973k|    if (stream_metadata) {
  ------------------
  |  Branch (4553:9): [True: 0, False: 973k]
  ------------------
 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|   973k|    in->next_cache_update = INT64_MAX;
 4559|       |
 4560|   973k|    if (do_update) {
  ------------------
  |  Branch (4560:9): [True: 57.5k, False: 915k]
  ------------------
 4561|  57.5k|        uint64_t bytes = in->cache_unbuffered_read_bytes;
 4562|  57.5k|        in->cache_unbuffered_read_bytes = 0;
 4563|  57.5k|        in->last_speed_query = now;
 4564|  57.5k|        double speed = bytes / (diff / (double)MP_TIME_S_TO_NS(1));
  ------------------
  |  |   71|  57.5k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
 4565|  57.5k|        in->bytes_per_second = 0.5 * in->speed_query_prev_sample +
 4566|  57.5k|                               0.5 * speed;
 4567|  57.5k|        in->speed_query_prev_sample = speed;
 4568|  57.5k|    }
 4569|       |    // The idea is to update as long as there is "activity".
 4570|   973k|    if (in->bytes_per_second)
  ------------------
  |  Branch (4570:9): [True: 59.3k, False: 913k]
  ------------------
 4571|  59.3k|        in->next_cache_update = now + MP_TIME_S_TO_NS(1) + MP_TIME_US_TO_NS(1);
  ------------------
  |  |   71|  59.3k|#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|  59.3k|#define MP_TIME_US_TO_NS(us) ((us) * INT64_C(1000))
  ------------------
 4572|   973k|}
demux.c:dumper_close:
 4575|   412k|{
 4576|   412k|    if (in->dumper)
  ------------------
  |  Branch (4576:9): [True: 0, False: 412k]
  ------------------
 4577|      0|        mp_recorder_destroy(in->dumper);
 4578|   412k|    in->dumper = NULL;
 4579|   412k|    if (in->dumper_status == CONTROL_TRUE)
  ------------------
  |  |   96|   412k|#define CONTROL_TRUE 1
  ------------------
  |  Branch (4579:9): [True: 0, False: 412k]
  ------------------
 4580|      0|        in->dumper_status = CONTROL_FALSE; // make abort equal to success
  ------------------
  |  |   97|      0|#define CONTROL_FALSE 0
  ------------------
 4581|   412k|}
demux.c:find_cache_seek_range:
 3938|  2.34k|{
 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|  2.34k|    if ((flags & SEEK_FACTOR) || !in->seekable_cache)
  ------------------
  |  |   94|  2.34k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (3943:9): [True: 0, False: 2.34k]
  |  Branch (3943:34): [True: 2.34k, False: 0]
  ------------------
 3944|  2.34k|        return NULL;
 3945|       |
 3946|      0|    struct demux_cached_range *res = NULL;
 3947|       |
 3948|      0|    for (int n = 0; n < in->num_ranges; n++) {
  ------------------
  |  Branch (3948:21): [True: 0, False: 0]
  ------------------
 3949|      0|        struct demux_cached_range *r = in->ranges[n];
 3950|      0|        if (r->seek_start != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (3950:13): [True: 0, False: 0]
  ------------------
 3951|      0|            MP_VERBOSE(in, "cached range %d: %f <-> %f (bof=%d, eof=%d)\n",
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3952|      0|                       n, r->seek_start, r->seek_end, r->is_bof, r->is_eof);
 3953|       |
 3954|      0|            if ((pts >= r->seek_start || r->is_bof) &&
  ------------------
  |  Branch (3954:18): [True: 0, False: 0]
  |  Branch (3954:42): [True: 0, False: 0]
  ------------------
 3955|      0|                (pts <= r->seek_end || r->is_eof))
  ------------------
  |  Branch (3955:18): [True: 0, False: 0]
  |  Branch (3955:40): [True: 0, False: 0]
  ------------------
 3956|      0|            {
 3957|      0|                MP_VERBOSE(in, "...using this range for in-cache seek.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 3958|      0|                res = r;
 3959|      0|                break;
 3960|      0|            }
 3961|      0|        }
 3962|      0|    }
 3963|       |
 3964|      0|    return res;
 3965|  2.34k|}
demux.c:compute_keyframe_times:
 1981|   875k|{
 1982|   875k|    struct demux_packet *start = pkt;
 1983|   875k|    double min = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1984|   875k|    double max = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   875k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1985|       |
 1986|  1.68M|    while (pkt) {
  ------------------
  |  Branch (1986:12): [True: 1.57M, False: 104k]
  ------------------
 1987|  1.57M|        if (pkt->keyframe && pkt != start)
  ------------------
  |  Branch (1987:13): [True: 1.57M, False: 0]
  |  Branch (1987:30): [True: 771k, False: 806k]
  ------------------
 1988|   771k|            break;
 1989|       |
 1990|   806k|        double ts = MP_PTS_OR_DEF(pkt->pts, pkt->dts);
  ------------------
  |  |   62|   806k|#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))
  |  |  ------------------
  |  |  |  |   39|   806k|#define MP_NOPTS_VALUE (-0x1p+63)
  |  |  ------------------
  |  |  |  Branch (62:32): [True: 0, False: 806k]
  |  |  ------------------
  ------------------
 1991|   806k|        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: 806k]
  |  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|   806k|        min = MP_PTS_MIN(min, ts);
  ------------------
  |  |   64|   806k|#define MP_PTS_MIN(a, b) MPMIN(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   45|  1.61M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (45:22): [True: 0, False: 806k]
  |  |  |  |  |  Branch (45:23): [True: 806k, False: 0]
  |  |  |  |  |  Branch (45:29): [True: 0, False: 806k]
  |  |  |  |  |  Branch (45:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (45:41): [True: 806k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1996|   806k|        max = MP_PTS_MAX(max, ts);
  ------------------
  |  |   65|   806k|#define MP_PTS_MAX(a, b) MPMAX(MP_PTS_OR_DEF(a, b), MP_PTS_OR_DEF(b, a))
  |  |  ------------------
  |  |  |  |   44|  1.61M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:22): [True: 0, False: 806k]
  |  |  |  |  |  Branch (44:23): [True: 806k, False: 0]
  |  |  |  |  |  Branch (44:29): [True: 0, False: 806k]
  |  |  |  |  |  Branch (44:35): [True: 0, False: 0]
  |  |  |  |  |  Branch (44:41): [True: 0, False: 806k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|       |
 1998|   806k|        pkt = pkt->next;
 1999|   806k|    }
 2000|       |
 2001|   875k|    if (out_kf_min)
  ------------------
  |  Branch (2001:9): [True: 875k, False: 0]
  ------------------
 2002|   875k|        *out_kf_min = min;
 2003|   875k|    if (out_kf_max)
  ------------------
  |  Branch (2003:9): [True: 0, False: 875k]
  ------------------
 2004|      0|        *out_kf_max = max;
 2005|   875k|    return pkt;
 2006|   875k|}
demux.c:update_bytes_read:
 4505|   973k|{
 4506|   973k|    struct demuxer *demuxer = in->d_thread;
 4507|       |
 4508|   973k|    int64_t new = in->slave_unbuffered_read_bytes;
 4509|   973k|    in->slave_unbuffered_read_bytes = 0;
 4510|       |
 4511|   973k|    int64_t new_seeks = 0;
 4512|       |
 4513|   973k|    struct stream *stream = demuxer->stream;
 4514|   973k|    if (stream) {
  ------------------
  |  Branch (4514:9): [True: 958k, False: 14.8k]
  ------------------
 4515|   958k|        new += stream->total_unbuffered_read_bytes;
 4516|   958k|        stream->total_unbuffered_read_bytes = 0;
 4517|   958k|        new_seeks += stream->total_stream_seeks;
 4518|   958k|        stream->total_stream_seeks = 0;
 4519|   958k|    }
 4520|       |
 4521|   973k|    in->cache_unbuffered_read_bytes += new;
 4522|   973k|    in->hack_unbuffered_read_bytes += new;
 4523|   973k|    in->byte_level_seeks += new_seeks;
 4524|   973k|}
demux.c:get_forward_buffered_bytes:
  491|  6.28M|{
  492|  6.28M|    if (!ds->reader_head)
  ------------------
  |  Branch (492:9): [True: 433k, False: 5.84M]
  ------------------
  493|   433k|        return 0;
  494|  5.84M|    return ds->queue->tail_cum_pos - ds->reader_head->cum_pos;
  495|  6.28M|}
demux.c:get_demux_sub_opts:
 5061|   422k|{
 5062|   422k|    if (!demuxer_list[index])
  ------------------
  |  Branch (5062:9): [True: 32.5k, False: 390k]
  ------------------
 5063|  32.5k|        return false;
 5064|   390k|    *sub = demuxer_list[index]->options;
 5065|       |    return true;
 5066|   422k|}

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

demux_disc.c:d_open:
 1133|  40.0k|{
 1134|  40.0k|    struct priv *p = demuxer->priv = talloc_zero(demuxer, struct priv);
  ------------------
  |  |   27|  40.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  40.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  40.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1135|  40.0k|    p->disc_audio_id = -1;
 1136|  40.0k|    p->applied_seg = -1;
 1137|  40.0k|    p->skip_until = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  40.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1138|       |
 1139|  40.0k|    if (check != DEMUX_CHECK_FORCE)
  ------------------
  |  Branch (1139:9): [True: 40.0k, False: 0]
  ------------------
 1140|  40.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|  40.0k|{
  100|  1.32M|    for (int i = 0; i < MAX_DVD_SPU_STREAMS; i++) {
  ------------------
  |  |   32|  1.32M|#define MAX_DVD_SPU_STREAMS 32
  ------------------
  |  Branch (100:21): [True: 1.28M, False: 40.0k]
  ------------------
  101|  1.28M|        talloc_free(p->dvd_sub_hold[i].pkt);
  ------------------
  |  |   47|  1.28M|#define talloc_free                     ta_free
  ------------------
  102|  1.28M|        p->dvd_sub_hold[i] = (struct dvd_sub_hold){0};
  103|  1.28M|    }
  104|  40.0k|}
demux_disc.c:d_close:
 1216|  40.0k|{
 1217|  40.0k|    struct priv *p = demuxer->priv;
 1218|  40.0k|    clear_dvd_sub_holds(p);
 1219|       |    TA_FREEP(&p->pending_pkt);
  ------------------
  |  |   81|  40.0k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  40.0k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 40.0k]
  |  |  ------------------
  ------------------
 1220|  40.0k|    demux_free(p->slave);
 1221|  40.0k|}

demux_edl.c:try_open_file:
  648|  40.0k|{
  649|  40.0k|    if (!demuxer->access_references)
  ------------------
  |  Branch (649:9): [True: 0, False: 40.0k]
  ------------------
  650|      0|        return -1;
  651|       |
  652|  40.0k|    struct priv *p = talloc_zero(demuxer, struct priv);
  ------------------
  |  |   27|  40.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  40.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  40.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|  40.0k|    demuxer->priv = p;
  654|  40.0k|    demuxer->fully_read = true;
  655|       |
  656|  40.0k|    struct stream *s = demuxer->stream;
  657|  40.0k|    if (s->info && strcmp(s->info->name, "edl") == 0) {
  ------------------
  |  Branch (657:9): [True: 40.0k, False: 0]
  |  Branch (657:20): [True: 0, False: 40.0k]
  ------------------
  658|      0|        p->data = bstr0(s->path);
  659|      0|        return 0;
  660|      0|    }
  661|  40.0k|    if (check >= DEMUX_CHECK_UNSAFE) {
  ------------------
  |  Branch (661:9): [True: 40.0k, False: 0]
  ------------------
  662|  40.0k|        char header[sizeof(HEADER) - 1];
  663|  40.0k|        int len = stream_read_peek(s, header, sizeof(header));
  664|  40.0k|        if (len != strlen(HEADER) || memcmp(header, HEADER, len) != 0)
  ------------------
  |  |   39|  40.0k|#define HEADER "# mpv EDL v0\n"
  ------------------
                      if (len != strlen(HEADER) || memcmp(header, HEADER, len) != 0)
  ------------------
  |  |   39|  35.5k|#define HEADER "# mpv EDL v0\n"
  ------------------
  |  Branch (664:13): [True: 4.49k, False: 35.5k]
  |  Branch (664:38): [True: 35.5k, False: 0]
  ------------------
  665|  40.0k|            return -1;
  666|  40.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_lavf.c:demux_open_lavf:
 1461|  71.9k|{
 1462|  71.9k|    AVFormatContext *avfc = NULL;
 1463|  71.9k|    AVDictionaryEntry *t = NULL;
 1464|  71.9k|    float analyze_duration = 0;
 1465|  71.9k|    lavf_priv_t *priv = talloc_zero(NULL, lavf_priv_t);
  ------------------
  |  |   27|  71.9k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  71.9k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  71.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1466|  71.9k|    AVDictionary *dopts = NULL;
 1467|       |
 1468|  71.9k|    demuxer->priv = priv;
 1469|  71.9k|    priv->stream = demuxer->stream;
 1470|       |
 1471|  71.9k|    priv->opts = mp_get_config_group(priv, demuxer->global, &demux_lavf_conf);
 1472|  71.9k|    struct demux_lavf_opts *lavfdopts = priv->opts;
 1473|       |
 1474|  71.9k|    if (lavf_check_file(demuxer, check) < 0)
  ------------------
  |  Branch (1474:9): [True: 11.9k, False: 60.0k]
  ------------------
 1475|  11.9k|        goto fail;
 1476|       |
 1477|  60.0k|    avfc = avformat_alloc_context();
 1478|  60.0k|    if (!avfc)
  ------------------
  |  Branch (1478:9): [True: 0, False: 60.0k]
  ------------------
 1479|      0|        goto fail;
 1480|       |
 1481|  60.0k|    if (demuxer->opts->index_mode != 1)
  ------------------
  |  Branch (1481:9): [True: 0, False: 60.0k]
  ------------------
 1482|      0|        avfc->flags |= AVFMT_FLAG_IGNIDX;
 1483|       |
 1484|  60.0k|    if (lavfdopts->probesize) {
  ------------------
  |  Branch (1484:9): [True: 0, False: 60.0k]
  ------------------
 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|  60.0k|    if (priv->format_hack.analyzeduration)
  ------------------
  |  Branch (1490:9): [True: 0, False: 60.0k]
  ------------------
 1491|      0|        analyze_duration = priv->format_hack.analyzeduration;
 1492|  60.0k|    if (lavfdopts->analyzeduration)
  ------------------
  |  Branch (1492:9): [True: 0, False: 60.0k]
  ------------------
 1493|      0|        analyze_duration = lavfdopts->analyzeduration;
 1494|  60.0k|    if (analyze_duration > 0) {
  ------------------
  |  Branch (1494:9): [True: 0, False: 60.0k]
  ------------------
 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|  60.0k|    if (priv->format_hack.no_ext_picky) {
  ------------------
  |  Branch (1501:9): [True: 0, False: 60.0k]
  ------------------
 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|  60.0k|    if ((priv->avif_flags & AVFMT_NOFILE) || priv->format_hack.nested_network) {
  ------------------
  |  Branch (1513:9): [True: 32.5k, False: 27.5k]
  |  Branch (1513:46): [True: 0, False: 27.5k]
  ------------------
 1514|  32.5k|        mp_setup_av_network_options(&dopts, priv->avif->name,
 1515|  32.5k|                                    demuxer->global, demuxer->log);
 1516|       |        // This might be incorrect.
 1517|  32.5k|        demuxer->seekable = true;
 1518|  32.5k|    }
 1519|       |
 1520|  60.0k|    if (!(priv->avif_flags & AVFMT_NOFILE)) {
  ------------------
  |  Branch (1520:9): [True: 27.5k, False: 32.5k]
  ------------------
 1521|  27.5k|        void *buffer = av_malloc(lavfdopts->buffersize);
 1522|  27.5k|        if (!buffer)
  ------------------
  |  Branch (1522:13): [True: 0, False: 27.5k]
  ------------------
 1523|      0|            goto fail;
 1524|  27.5k|        const char *location = priv->stream->effective_url;
 1525|  27.5k|        priv->avio_cookie = (struct avio_cookie){
 1526|  27.5k|            .av_class = &avio_cookie_class,
 1527|  27.5k|            .demuxer = demuxer,
 1528|  27.5k|            .location = location ? location : priv->filename,
  ------------------
  |  Branch (1528:25): [True: 0, False: 27.5k]
  ------------------
 1529|  27.5k|        };
 1530|  27.5k|        priv->pb = avio_alloc_context(buffer, lavfdopts->buffersize, 0,
 1531|  27.5k|                                      &priv->avio_cookie, mp_read, NULL,
 1532|  27.5k|                                      mp_seek);
 1533|  27.5k|        if (!priv->pb) {
  ------------------
  |  Branch (1533:13): [True: 0, False: 27.5k]
  ------------------
 1534|      0|            av_free(buffer);
 1535|      0|            goto fail;
 1536|      0|        }
 1537|  27.5k|        priv->pb->av_class = &avio_class;
 1538|  27.5k|        priv->pb->read_seek = mp_read_seek;
 1539|  27.5k|        priv->pb->seekable = demuxer->seekable ? AVIO_SEEKABLE_NORMAL : 0;
  ------------------
  |  Branch (1539:30): [True: 27.5k, False: 0]
  ------------------
 1540|  27.5k|        avfc->pb = priv->pb;
 1541|  27.5k|        if (stream_control(priv->stream, STREAM_CTRL_HAS_AVSEEK, NULL) > 0)
  ------------------
  |  Branch (1541:13): [True: 0, False: 27.5k]
  ------------------
 1542|      0|            demuxer->seekable = true;
 1543|  27.5k|        demuxer->seekable |= priv->format_hack.fully_read;
 1544|  27.5k|    }
 1545|       |
 1546|  60.0k|    if (matches_avinputformat_name(priv, "rtsp")) {
  ------------------
  |  Branch (1546:9): [True: 0, False: 60.0k]
  ------------------
 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|  60.0k|    guess_and_set_vobsub_name(demuxer, &dopts);
 1559|       |
 1560|  60.0k|    avfc->interrupt_callback = (AVIOInterruptCB){
 1561|  60.0k|        .callback = interrupt_cb,
 1562|  60.0k|        .opaque = demuxer,
 1563|  60.0k|    };
 1564|       |
 1565|  60.0k|    avfc->opaque = demuxer;
 1566|  60.0k|    if (demuxer->access_references) {
  ------------------
  |  Branch (1566:9): [True: 60.0k, False: 0]
  ------------------
 1567|  60.0k|        priv->default_io_open = avfc->io_open;
 1568|  60.0k|        avfc->io_open = nested_io_open;
 1569|  60.0k|        priv->default_io_close2 = avfc->io_close2;
 1570|  60.0k|        avfc->io_close2 = nested_io_close2;
 1571|  60.0k|    } 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|  60.0k|    mp_set_avdict(&dopts, lavfdopts->avopts);
 1592|       |
 1593|  60.0k|    if (av_dict_copy(&priv->av_opts, dopts, 0) < 0) {
  ------------------
  |  Branch (1593:9): [True: 0, False: 60.0k]
  ------------------
 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|  60.0k|    if (priv->format_hack.readall_on_no_streamseek && priv->pb &&
  ------------------
  |  Branch (1598:9): [True: 0, False: 60.0k]
  |  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|  60.0k|    if (avformat_open_input(&avfc, priv->filename, priv->avif, &dopts) < 0) {
  ------------------
  |  Branch (1612:9): [True: 1.67k, False: 58.3k]
  ------------------
 1613|  1.67k|        MP_ERR(demuxer, "avformat_open_input() failed\n");
  ------------------
  |  |   89|  1.67k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.67k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1614|  1.67k|        goto fail;
 1615|  1.67k|    }
 1616|       |
 1617|  58.3k|    mp_avdict_print_unset(demuxer->log, MSGL_V, dopts);
 1618|  58.3k|    av_dict_free(&dopts);
 1619|       |
 1620|  58.3k|    priv->avfc = avfc;
 1621|       |
 1622|  58.3k|    bool probeinfo = lavfdopts->probeinfo != 0;
 1623|  58.3k|    switch (lavfdopts->probeinfo) {
  ------------------
  |  Branch (1623:13): [True: 58.3k, False: 0]
  ------------------
 1624|      0|    case -2: probeinfo = priv->avfc->nb_streams == 0; break;
  ------------------
  |  Branch (1624:5): [True: 0, False: 58.3k]
  ------------------
 1625|  58.3k|    case -1: probeinfo = !priv->format_hack.skipinfo; break;
  ------------------
  |  Branch (1625:5): [True: 58.3k, False: 0]
  ------------------
 1626|  58.3k|    }
 1627|  58.3k|    if (demuxer->params && demuxer->params->skip_lavf_probing)
  ------------------
  |  Branch (1627:9): [True: 58.3k, False: 0]
  |  Branch (1627:28): [True: 0, False: 58.3k]
  ------------------
 1628|      0|        probeinfo = false;
 1629|  58.3k|    if (probeinfo) {
  ------------------
  |  Branch (1629:9): [True: 57.9k, False: 434]
  ------------------
 1630|  57.9k|        int nb_streams = avfc->nb_streams;
 1631|  57.9k|        AVDictionary **opts = talloc_zero_array(NULL, AVDictionary *, nb_streams);
  ------------------
  |  |   30|  57.9k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  57.9k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  57.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1632|  57.9k|#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(61, 7, 100)
 1633|   108k|        for (int i = 0; i < nb_streams; i++) {
  ------------------
  |  Branch (1633:25): [True: 50.1k, False: 57.9k]
  ------------------
 1634|  50.1k|            AVCodecParameters *par = avfc->streams[i]->codecpar;
 1635|  50.1k|            if (par->codec_type == AVMEDIA_TYPE_AUDIO && par->format == AV_SAMPLE_FMT_DSD)
  ------------------
  |  Branch (1635:17): [True: 934, False: 49.1k]
  |  Branch (1635:58): [True: 0, False: 934]
  ------------------
 1636|      0|                av_dict_set(&opts[i], "request_sample_fmt", "dsd", 0);
 1637|  50.1k|        }
 1638|  57.9k|#endif
 1639|  57.9k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1640|   108k|        for (int i = 0; i < nb_streams; i++)
  ------------------
  |  Branch (1640:25): [True: 50.1k, False: 57.9k]
  ------------------
 1641|  50.1k|            av_dict_set_int(&opts[i], "max_pixels", 2048 * 2048, 0);
 1642|  57.9k|#endif
 1643|  57.9k|        int r = avformat_find_stream_info(avfc, opts);
 1644|   108k|        for (int i = 0; i < nb_streams; i++)
  ------------------
  |  Branch (1644:25): [True: 50.1k, False: 57.9k]
  ------------------
 1645|  50.1k|            av_dict_free(&opts[i]);
 1646|  57.9k|        talloc_free(opts);
  ------------------
  |  |   47|  57.9k|#define talloc_free                     ta_free
  ------------------
 1647|  57.9k|        if (r < 0) {
  ------------------
  |  Branch (1647:13): [True: 1.38k, False: 56.5k]
  ------------------
 1648|  1.38k|            MP_ERR(demuxer, "av_find_stream_info() failed\n");
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1649|  1.38k|            goto fail;
 1650|  1.38k|        }
 1651|       |
 1652|  56.5k|        MP_VERBOSE(demuxer, "avformat_find_stream_info() finished after %"PRId64
  ------------------
  |  |   92|  56.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  56.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1653|  56.5k|                   " bytes.\n", stream_tell(priv->stream));
 1654|  56.5k|    }
 1655|       |
 1656|  56.9k|    for (int i = 0; i < avfc->nb_chapters; i++) {
  ------------------
  |  Branch (1656:21): [True: 0, False: 56.9k]
  ------------------
 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|  56.9k|    add_new_streams(demuxer);
 1665|  56.9k|    build_editions(demuxer);
 1666|  56.9k|#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 19, 100)
 1667|  56.9k|    handle_stream_groups(demuxer);
 1668|  56.9k|#endif
 1669|  56.9k|    detect_dovi_split_streams(demuxer);
 1670|       |
 1671|  56.9k|    mp_tags_move_from_av_dictionary(demuxer->metadata, &avfc->metadata);
 1672|       |
 1673|  56.9k|    demuxer->ts_resets_possible =
 1674|  56.9k|        priv->avif_flags & (AVFMT_TS_DISCONT | AVFMT_NOTIMESTAMPS);
 1675|       |
 1676|  56.9k|    if (avfc->start_time != AV_NOPTS_VALUE)
  ------------------
  |  Branch (1676:9): [True: 39.3k, False: 17.6k]
  ------------------
 1677|  39.3k|        demuxer->start_time = avfc->start_time / (double)AV_TIME_BASE;
 1678|       |
 1679|  56.9k|    demuxer->fully_read = priv->format_hack.fully_read;
 1680|       |
 1681|  56.9k|#ifdef AVFMTCTX_UNSEEKABLE
 1682|  56.9k|    if (avfc->ctx_flags & AVFMTCTX_UNSEEKABLE)
  ------------------
  |  Branch (1682:9): [True: 0, False: 56.9k]
  ------------------
 1683|      0|        demuxer->seekable = false;
 1684|  56.9k|#endif
 1685|       |
 1686|  56.9k|    demuxer->is_network |= priv->format_hack.is_network;
 1687|  56.9k|    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|  56.9k|    double total_duration = -1;
 1693|  56.9k|    double av_duration = -1;
 1694|   137k|    for (int n = 0; n < priv->avfc->nb_streams; n++) {
  ------------------
  |  Branch (1694:21): [True: 80.1k, False: 56.9k]
  ------------------
 1695|  80.1k|        AVStream *st = priv->avfc->streams[n];
 1696|  80.1k|        if (st->duration <= 0)
  ------------------
  |  Branch (1696:13): [True: 75.3k, False: 4.84k]
  ------------------
 1697|  75.3k|            continue;
 1698|  4.84k|        double f_duration = st->duration * av_q2d(st->time_base);
 1699|  4.84k|        total_duration = MPMAX(total_duration, f_duration);
  ------------------
  |  |   44|  4.84k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 376, False: 4.47k]
  |  |  ------------------
  ------------------
 1700|  4.84k|        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ||
  ------------------
  |  Branch (1700:13): [True: 2.23k, False: 2.61k]
  ------------------
 1701|  2.61k|            st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
  ------------------
  |  Branch (1701:13): [True: 2.49k, False: 114]
  ------------------
 1702|  4.73k|            av_duration = MPMAX(av_duration, f_duration);
  ------------------
  |  |   44|  4.73k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 363, False: 4.37k]
  |  |  ------------------
  ------------------
 1703|  4.84k|    }
 1704|  56.9k|    double duration = av_duration > 0 ? av_duration : total_duration;
  ------------------
  |  Branch (1704:23): [True: 3.76k, False: 53.2k]
  ------------------
 1705|  56.9k|    if (duration <= 0 && priv->avfc->duration > 0)
  ------------------
  |  Branch (1705:9): [True: 53.2k, False: 3.77k]
  |  Branch (1705:26): [True: 102, False: 53.1k]
  ------------------
 1706|    102|        duration = (double)priv->avfc->duration / AV_TIME_BASE;
 1707|  56.9k|    demuxer->duration = duration;
 1708|       |
 1709|  56.9k|    if (demuxer->duration < 0 && priv->format_hack.no_seek_on_no_duration)
  ------------------
  |  Branch (1709:9): [True: 53.1k, False: 3.87k]
  |  Branch (1709:34): [True: 0, False: 53.1k]
  ------------------
 1710|      0|        demuxer->seekable = false;
 1711|       |
 1712|       |    // In some cases, libavformat will export bogus bullshit timestamps anyway,
 1713|       |    // such as with mjpeg.
 1714|  56.9k|    if (priv->avif_flags & AVFMT_NOTIMESTAMPS) {
  ------------------
  |  Branch (1714:9): [True: 5.44k, False: 51.5k]
  ------------------
 1715|  5.44k|        MP_WARN(demuxer,
  ------------------
  |  |   90|  5.44k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.44k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1716|  5.44k|                "This format is marked by FFmpeg as having no timestamps!\n"
 1717|  5.44k|                "FFmpeg will likely make up its own broken timestamps. For\n"
 1718|  5.44k|                "video streams you can correct this with:\n"
 1719|  5.44k|                "    --no-correct-pts --container-fps-override=VALUE\n"
 1720|  5.44k|                "with VALUE being the real framerate of the stream. You can\n"
 1721|  5.44k|                "expect seeking and buffering estimation to be generally\n"
 1722|  5.44k|                "broken as well.\n");
 1723|  5.44k|    }
 1724|       |
 1725|  56.9k|    if (demuxer->fully_read) {
  ------------------
  |  Branch (1725:9): [True: 2.34k, False: 54.6k]
  ------------------
 1726|  2.34k|        demux_close_stream(demuxer);
 1727|  2.34k|        if (priv->own_stream)
  ------------------
  |  Branch (1727:13): [True: 2.28k, False: 62]
  ------------------
 1728|  2.28k|            free_stream(priv->stream);
 1729|  2.34k|        priv->own_stream = false;
 1730|  2.34k|        priv->stream = NULL;
 1731|  2.34k|    }
 1732|       |
 1733|  56.9k|    if (priv->stream) {
  ------------------
  |  Branch (1733:9): [True: 54.6k, False: 2.34k]
  ------------------
 1734|  54.6k|        const char *sname = priv->stream->info->name;
 1735|  54.6k|        priv->is_dvd = strcmp(sname, "dvdnav") == 0 ||
  ------------------
  |  Branch (1735:24): [True: 0, False: 54.6k]
  ------------------
 1736|  54.6k|                       strcmp(sname, "ifo_dvdnav") == 0;
  ------------------
  |  Branch (1736:24): [True: 0, False: 54.6k]
  ------------------
 1737|  54.6k|        priv->is_dvd_bd = priv->is_dvd ||
  ------------------
  |  Branch (1737:27): [True: 0, False: 54.6k]
  ------------------
 1738|  54.6k|                          strcmp(sname, "bd") == 0 ||
  ------------------
  |  Branch (1738:27): [True: 0, False: 54.6k]
  ------------------
 1739|  54.6k|                          strcmp(sname, "bdnav") == 0 ||
  ------------------
  |  Branch (1739:27): [True: 0, False: 54.6k]
  ------------------
 1740|  54.6k|                          strcmp(sname, "bdmv/bluray") == 0;
  ------------------
  |  Branch (1740:27): [True: 0, False: 54.6k]
  ------------------
 1741|  54.6k|    }
 1742|       |
 1743|  56.9k|    return 0;
 1744|       |
 1745|  15.0k|fail:
 1746|  15.0k|    if (!priv->avfc)
  ------------------
  |  Branch (1746:9): [True: 13.6k, False: 1.38k]
  ------------------
 1747|  13.6k|        avformat_free_context(avfc);
 1748|  15.0k|    av_dict_free(&dopts);
 1749|       |
 1750|  15.0k|    return -1;
 1751|  58.3k|}
demux_lavf.c:lavf_check_file:
  471|  71.9k|{
  472|  71.9k|    lavf_priv_t *priv = demuxer->priv;
  473|  71.9k|    struct demux_lavf_opts *lavfdopts = priv->opts;
  474|  71.9k|    struct stream *s = priv->stream;
  475|       |
  476|  71.9k|    priv->filename = remove_prefix(s->url, prefixes);
  477|       |
  478|  71.9k|    char *avdevice_format = NULL;
  479|  71.9k|    if (s->info && strcmp(s->info->name, "avdevice") == 0) {
  ------------------
  |  Branch (479:9): [True: 71.9k, False: 0]
  |  Branch (479:20): [True: 32.5k, False: 39.4k]
  ------------------
  480|       |        // always require filename in the form "format:filename"
  481|  32.5k|        char *sep = strchr(priv->filename, ':');
  482|  32.5k|        if (!sep) {
  ------------------
  |  Branch (482:13): [True: 0, False: 32.5k]
  ------------------
  483|      0|            MP_FATAL(demuxer, "Must specify filename in 'format:filename' form\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__)
  |  |  ------------------
  ------------------
  484|      0|            return -1;
  485|      0|        }
  486|  32.5k|        avdevice_format = talloc_strndup(priv, priv->filename,
  ------------------
  |  |   51|  32.5k|#define talloc_strndup                  ta_xstrndup
  ------------------
  487|  32.5k|                                         sep - priv->filename);
  488|  32.5k|        priv->filename = sep + 1;
  489|  32.5k|    }
  490|       |
  491|  71.9k|    char *mime_type = s->mime_type;
  492|  71.9k|    if (!lavfdopts->allow_mimetype || !mime_type)
  ------------------
  |  Branch (492:9): [True: 0, False: 71.9k]
  |  Branch (492:39): [True: 71.9k, False: 0]
  ------------------
  493|  71.9k|        mime_type = "";
  494|       |
  495|  71.9k|    const AVInputFormat *forced_format = NULL;
  496|  71.9k|    const char *format = lavfdopts->format;
  497|  71.9k|    if (!format || !format[0])
  ------------------
  |  Branch (497:9): [True: 71.9k, False: 0]
  |  Branch (497:20): [True: 0, False: 0]
  ------------------
  498|  71.9k|        format = s->lavf_type;
  499|  71.9k|    if (!format)
  ------------------
  |  Branch (499:9): [True: 71.9k, False: 0]
  ------------------
  500|  71.9k|        format = avdevice_format;
  501|  71.9k|    if (format) {
  ------------------
  |  Branch (501:9): [True: 32.5k, False: 39.4k]
  ------------------
  502|  32.5k|        if (strcmp(format, "help") == 0) {
  ------------------
  |  Branch (502:13): [True: 0, False: 32.5k]
  ------------------
  503|      0|            list_formats(demuxer);
  504|      0|            return -1;
  505|      0|        }
  506|  32.5k|        forced_format = av_find_input_format(format);
  507|  32.5k|        if (!forced_format) {
  ------------------
  |  Branch (507:13): [True: 0, False: 32.5k]
  ------------------
  508|      0|            MP_FATAL(demuxer, "Unknown lavf format %s\n", 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__)
  |  |  ------------------
  ------------------
  509|      0|            return -1;
  510|      0|        }
  511|  32.5k|    }
  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|  71.9k|    bstr ext = mp_get_ext(bstr_split(bstr0(priv->filename), "?#", NULL));
  516|  71.9k|    AVProbeData avpd = {
  517|       |        // Disable file-extension matching with normal checks, except for HLS
  518|  71.9k|        .filename = !bstrcasecmp0(ext, "m3u8") || !bstrcasecmp0(ext, "m3u") ||
  ------------------
  |  Branch (518:21): [True: 0, False: 71.9k]
  |  Branch (518:51): [True: 0, False: 71.9k]
  ------------------
  519|  71.9k|                    check <= DEMUX_CHECK_REQUEST ? priv->filename : "",
  ------------------
  |  Branch (519:21): [True: 40.0k, False: 31.9k]
  ------------------
  520|  71.9k|        .buf_size = 0,
  521|  71.9k|        .buf = av_malloc(PROBE_BUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE),
  ------------------
  |  |   65|  71.9k|#define PROBE_BUF_SIZE (10 * 1024 * 1024)
  ------------------
  522|  71.9k|        .mime_type = lavfdopts->allow_mimetype ? mime_type : NULL,
  ------------------
  |  Branch (522:22): [True: 71.9k, False: 0]
  ------------------
  523|  71.9k|    };
  524|  71.9k|    if (!avpd.buf)
  ------------------
  |  Branch (524:9): [True: 0, False: 71.9k]
  ------------------
  525|      0|        return -1;
  526|       |
  527|  71.9k|    bool final_probe = false;
  528|  95.9k|    do {
  529|  95.9k|        int score = 0;
  530|       |
  531|  95.9k|        if (forced_format) {
  ------------------
  |  Branch (531:13): [True: 32.5k, False: 63.4k]
  ------------------
  532|  32.5k|            priv->avif = forced_format;
  533|  32.5k|            score = AVPROBE_SCORE_MAX;
  534|  63.4k|        } else {
  535|  63.4k|            int nsize = av_clip(avpd.buf_size * 2, INITIAL_PROBE_SIZE,
  ------------------
  |  |   64|  63.4k|#define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE
  |  |  ------------------
  |  |  |  |   33|  63.4k|#define STREAM_BUFFER_SIZE 2048
  |  |  ------------------
  ------------------
  536|  63.4k|                                PROBE_BUF_SIZE);
  ------------------
  |  |   65|  63.4k|#define PROBE_BUF_SIZE (10 * 1024 * 1024)
  ------------------
  537|  63.4k|            nsize = stream_read_peek(s, avpd.buf, nsize);
  538|  63.4k|            memset(avpd.buf + nsize, 0, AV_INPUT_BUFFER_PADDING_SIZE);
  539|  63.4k|            if (nsize <= avpd.buf_size)
  ------------------
  |  Branch (539:17): [True: 12.0k, False: 51.3k]
  ------------------
  540|  12.0k|                final_probe = true;
  541|  63.4k|            avpd.buf_size = nsize;
  542|       |
  543|  63.4k|            priv->avif = av_probe_input_format2(&avpd, avpd.buf_size > 0, &score);
  544|  63.4k|        }
  545|       |
  546|  95.9k|        if (priv->avif) {
  ------------------
  |  Branch (546:13): [True: 73.1k, False: 22.7k]
  ------------------
  547|  73.1k|            MP_VERBOSE(demuxer, "Found '%s' at score=%d size=%d%s.\n",
  ------------------
  |  |   92|  73.1k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   146k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 32.5k, False: 40.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|  73.1k|                       priv->avif->name, score, avpd.buf_size,
  549|  73.1k|                       forced_format ? " (forced)" : "");
  550|       |
  551|  2.37M|            for (int n = 0; lavfdopts->hacks && format_hacks[n].ff_name; n++) {
  ------------------
  |  Branch (551:29): [True: 2.37M, False: 0]
  |  Branch (551:49): [True: 2.32M, False: 51.3k]
  ------------------
  552|  2.32M|                const struct format_hack *entry = &format_hacks[n];
  553|  2.32M|                if (!matches_avinputformat_name(priv, entry->ff_name))
  ------------------
  |  Branch (553:21): [True: 2.29M, False: 28.6k]
  ------------------
  554|  2.29M|                    continue;
  555|  28.6k|                if (entry->mime_type && strcasecmp(entry->mime_type, mime_type) != 0)
  ------------------
  |  Branch (555:21): [True: 6.90k, False: 21.7k]
  |  Branch (555:41): [True: 6.90k, False: 0]
  ------------------
  556|  6.90k|                    continue;
  557|  21.7k|                priv->format_hack = *entry;
  558|  21.7k|                break;
  559|  28.6k|            }
  560|       |
  561|       |            // AVIF always needs to find stream info
  562|  73.1k|            if (bstrcasecmp0(ext, "avif") == 0)
  ------------------
  |  Branch (562:17): [True: 0, False: 73.1k]
  ------------------
  563|      0|                priv->format_hack.skipinfo = false;
  564|       |
  565|  73.1k|            if (score >= lavfdopts->probescore)
  ------------------
  |  Branch (565:17): [True: 59.9k, False: 13.2k]
  ------------------
  566|  59.9k|                break;
  567|       |
  568|  13.2k|            if (priv->format_hack.probescore &&
  ------------------
  |  Branch (568:17): [True: 6.78k, False: 6.44k]
  ------------------
  569|  6.78k|                score >= priv->format_hack.probescore &&
  ------------------
  |  Branch (569:17): [True: 267, False: 6.51k]
  ------------------
  570|    267|                (!priv->format_hack.max_probe || final_probe))
  ------------------
  |  Branch (570:18): [True: 0, False: 267]
  |  Branch (570:50): [True: 127, False: 140]
  ------------------
  571|    127|                break;
  572|  13.2k|        }
  573|       |
  574|  35.8k|        priv->avif = NULL;
  575|  35.8k|        priv->format_hack = (struct format_hack){0};
  576|  35.8k|    } while (!final_probe);
  ------------------
  |  Branch (576:14): [True: 23.9k, False: 11.9k]
  ------------------
  577|       |
  578|  71.9k|    av_free(avpd.buf);
  579|       |
  580|  71.9k|    if (priv->avif && !forced_format && priv->format_hack.ignore) {
  ------------------
  |  Branch (580:9): [True: 60.0k, False: 11.9k]
  |  Branch (580:23): [True: 27.5k, False: 32.5k]
  |  Branch (580:41): [True: 0, False: 27.5k]
  ------------------
  581|      0|        MP_VERBOSE(demuxer, "Format blacklisted.\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__)
  |  |  ------------------
  ------------------
  582|      0|        priv->avif = NULL;
  583|      0|    }
  584|       |
  585|  71.9k|    if (!priv->avif) {
  ------------------
  |  Branch (585:9): [True: 11.9k, False: 60.0k]
  ------------------
  586|  11.9k|        MP_VERBOSE(demuxer, "No format found, try lowering probescore or forcing the format.\n");
  ------------------
  |  |   92|  11.9k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  11.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  587|  11.9k|        return -1;
  588|  11.9k|    }
  589|       |
  590|  60.0k|    if (lavfdopts->hacks)
  ------------------
  |  Branch (590:9): [True: 60.0k, False: 0]
  ------------------
  591|  60.0k|        priv->avif_flags = priv->avif->flags | priv->format_hack.if_flags;
  592|       |
  593|  60.0k|    priv->linearize_ts = lavfdopts->linearize_ts;
  594|  60.0k|    if (priv->linearize_ts < 0 && !priv->format_hack.linearize_audio_ts)
  ------------------
  |  Branch (594:9): [True: 60.0k, False: 0]
  |  Branch (594:35): [True: 60.0k, False: 34]
  ------------------
  595|  60.0k|        priv->linearize_ts = 0;
  596|       |
  597|  60.0k|    demuxer->filetype = priv->avif->name;
  598|       |
  599|  60.0k|    if (priv->format_hack.detect_charset)
  ------------------
  |  Branch (599:9): [True: 2.64k, False: 57.3k]
  ------------------
  600|  2.64k|        convert_charset(demuxer);
  601|       |
  602|  60.0k|    return 0;
  603|  71.9k|}
demux_lavf.c:remove_prefix:
  458|  71.9k|{
  459|   327k|    for (int n = 0; prefixes[n]; n++) {
  ------------------
  |  Branch (459:21): [True: 287k, False: 39.4k]
  ------------------
  460|   287k|        int len = strlen(prefixes[n]);
  461|   287k|        if (strncmp(s, prefixes[n], len) == 0)
  ------------------
  |  Branch (461:13): [True: 32.5k, False: 255k]
  ------------------
  462|  32.5k|            return s + len;
  463|   287k|    }
  464|  39.4k|    return s;
  465|  71.9k|}
demux_lavf.c:convert_charset:
  428|  2.64k|{
  429|  2.64k|    lavf_priv_t *priv = demuxer->priv;
  430|  2.64k|    char *cp = priv->opts->sub_cp;
  431|  2.64k|    if (!cp || !cp[0] || mp_charset_is_utf8(cp))
  ------------------
  |  Branch (431:9): [True: 0, False: 2.64k]
  |  Branch (431:16): [True: 0, False: 2.64k]
  |  Branch (431:26): [True: 0, False: 2.64k]
  ------------------
  432|      0|        return;
  433|  2.64k|    bstr data = stream_read_complete(priv->stream, NULL, 128 * 1024 * 1024);
  434|  2.64k|    if (!data.start) {
  ------------------
  |  Branch (434:9): [True: 0, False: 2.64k]
  ------------------
  435|      0|        MP_WARN(demuxer, "File too big (or error reading) - skip charset probing.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  436|      0|        return;
  437|      0|    }
  438|  2.64k|    void *alloc = data.start;
  439|  2.64k|    cp = (char *)mp_charset_guess(priv, demuxer->log, data, cp, 0);
  440|  2.64k|    if (cp && !mp_charset_is_utf8(cp))
  ------------------
  |  Branch (440:9): [True: 2.64k, False: 0]
  |  Branch (440:15): [True: 2.38k, False: 261]
  ------------------
  441|  2.64k|        MP_INFO(demuxer, "Using subtitle charset: %s\n", cp);
  ------------------
  |  |   91|  2.38k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.38k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  442|       |    // libavformat transparently converts UTF-16 to UTF-8
  443|  2.64k|    if (!mp_charset_is_utf16(cp) && !mp_charset_is_utf8(cp)) {
  ------------------
  |  Branch (443:9): [True: 2.63k, False: 10]
  |  Branch (443:37): [True: 2.37k, False: 261]
  ------------------
  444|  2.37k|        bstr conv = mp_iconv_to_utf8(demuxer->log, data, cp, MP_ICONV_VERBOSE);
  445|  2.37k|        if (conv.start && conv.start != data.start)
  ------------------
  |  Branch (445:13): [True: 2.37k, False: 0]
  |  Branch (445:27): [True: 2.37k, False: 0]
  ------------------
  446|  2.37k|            talloc_steal(alloc, conv.start);
  ------------------
  |  |   38|  2.37k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  2.37k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  447|  2.37k|        if (conv.start)
  ------------------
  |  Branch (447:13): [True: 2.37k, False: 0]
  ------------------
  448|  2.37k|            data = conv;
  449|  2.37k|    }
  450|  2.64k|    if (data.start) {
  ------------------
  |  Branch (450:9): [True: 2.64k, False: 0]
  ------------------
  451|  2.64k|        priv->stream = stream_memory_open(demuxer->global, data.start, data.len);
  452|  2.64k|        priv->own_stream = true;
  453|  2.64k|    }
  454|  2.64k|    talloc_free(alloc);
  ------------------
  |  |   47|  2.64k|#define talloc_free                     ta_free
  ------------------
  455|  2.64k|}
demux_lavf.c:mp_read:
  343|   218k|{
  344|   218k|    struct demuxer *demuxer = ((struct avio_cookie *)opaque)->demuxer;
  345|   218k|    lavf_priv_t *priv = demuxer->priv;
  346|   218k|    struct stream *stream = priv->stream;
  347|   218k|    if (!stream)
  ------------------
  |  Branch (347:9): [True: 0, False: 218k]
  ------------------
  348|      0|        return 0;
  349|       |
  350|   218k|    int ret = stream_read_partial(stream, buf, size);
  351|       |
  352|   218k|    MP_TRACE(demuxer, "%d=mp_read(%p, %p, %d), pos: %"PRId64", eof:%d\n",
  ------------------
  |  |   94|   218k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   218k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  353|   218k|             ret, stream, buf, size, stream_tell(stream), stream->eof);
  354|   218k|    return ret ? ret : AVERROR_EOF;
  ------------------
  |  Branch (354:12): [True: 33.2k, False: 185k]
  ------------------
  355|   218k|}
demux_lavf.c:mp_seek:
  358|  80.6k|{
  359|  80.6k|    struct demuxer *demuxer = ((struct avio_cookie *)opaque)->demuxer;
  360|  80.6k|    lavf_priv_t *priv = demuxer->priv;
  361|  80.6k|    struct stream *stream = priv->stream;
  362|  80.6k|    if (!stream)
  ------------------
  |  Branch (362:9): [True: 0, False: 80.6k]
  ------------------
  363|      0|        return -1;
  364|       |
  365|  80.6k|    MP_TRACE(demuxer, "mp_seek(%p, %"PRId64", %s)\n", stream, pos,
  ------------------
  |  |   94|  80.6k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   483k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 10.1k, False: 70.5k]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 80.6k]
  |  |  |  |  |  Branch (86:57): [True: 0, False: 80.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|  80.6k|             whence == SEEK_END ? "end" :
  367|  80.6k|             whence == SEEK_CUR ? "cur" :
  368|  80.6k|             whence == SEEK_SET ? "set" : "size");
  369|  80.6k|    if (whence == SEEK_END || whence == AVSEEK_SIZE) {
  ------------------
  |  Branch (369:9): [True: 0, False: 80.6k]
  |  Branch (369:31): [True: 70.5k, False: 10.1k]
  ------------------
  370|  70.5k|        int64_t end = stream_get_size(stream);
  371|  70.5k|        if (end < 0)
  ------------------
  |  Branch (371:13): [True: 0, False: 70.5k]
  ------------------
  372|      0|            return -1;
  373|  70.5k|        if (whence == AVSEEK_SIZE)
  ------------------
  |  Branch (373:13): [True: 70.5k, False: 0]
  ------------------
  374|  70.5k|            return end;
  375|      0|        pos += end;
  376|  10.1k|    } else if (whence == SEEK_CUR) {
  ------------------
  |  Branch (376:16): [True: 0, False: 10.1k]
  ------------------
  377|      0|        pos += stream_tell(stream);
  378|  10.1k|    } else if (whence != SEEK_SET) {
  ------------------
  |  Branch (378:16): [True: 0, False: 10.1k]
  ------------------
  379|      0|        return -1;
  380|      0|    }
  381|       |
  382|  10.1k|    if (pos < 0)
  ------------------
  |  Branch (382:9): [True: 0, False: 10.1k]
  ------------------
  383|      0|        return -1;
  384|       |
  385|  10.1k|    int64_t current_pos = stream_tell(stream);
  386|  10.1k|    if (!priv->is_dvd_bd) {
  ------------------
  |  Branch (386:9): [True: 10.1k, False: 0]
  ------------------
  387|  10.1k|        if (stream_seek(stream, pos) == 0) {
  ------------------
  |  Branch (387:13): [True: 7.16k, False: 2.96k]
  ------------------
  388|  7.16k|            stream_seek(stream, current_pos);
  389|  7.16k|            return -1;
  390|  7.16k|        }
  391|  10.1k|    } else {
  392|      0|        stream_drop_buffers(stream);
  393|      0|        stream->pos = current_pos;
  394|      0|    }
  395|       |
  396|  2.96k|    return pos;
  397|  10.1k|}
demux_lavf.c:avio_child_next:
  330|   179k|{
  331|   179k|    AVIOContext *pb = obj;
  332|   179k|    return prev ? NULL : pb->opaque;
  ------------------
  |  Branch (332:12): [True: 89.5k, False: 89.5k]
  ------------------
  333|   179k|}
demux_lavf.c:matches_avinputformat_name:
  304|  2.49M|{
  305|  2.49M|    const char *avifname = priv->avif->name;
  306|  2.51M|    while (1) {
  ------------------
  |  Branch (306:12): [True: 2.51M, Folded]
  ------------------
  307|  2.51M|        const char *next = strchr(avifname, ',');
  308|  2.51M|        if (!next)
  ------------------
  |  Branch (308:13): [True: 2.49M, False: 28.2k]
  ------------------
  309|  2.49M|            return !strcmp(avifname, name);
  310|  28.2k|        int len = next - avifname;
  311|  28.2k|        if (len == strlen(name) && !memcmp(avifname, name, len))
  ------------------
  |  Branch (311:13): [True: 6.20k, False: 22.0k]
  |  Branch (311:36): [True: 1.29k, False: 4.90k]
  ------------------
  312|  1.29k|            return true;
  313|  26.9k|        avifname = next + 1;
  314|  26.9k|    }
  315|  2.49M|}
demux_lavf.c:guess_and_set_vobsub_name:
  614|  60.0k|{
  615|  60.0k|    lavf_priv_t *priv = demuxer->priv;
  616|  60.0k|    if (!matches_avinputformat_name(priv, "vobsub"))
  ------------------
  |  Branch (616:9): [True: 60.0k, False: 0]
  ------------------
  617|  60.0k|        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|   380k|{
  980|   380k|    return demux_read_interrupted(ctx);
  981|   380k|}
demux_lavf.c:add_new_streams:
  962|   933k|{
  963|   933k|    lavf_priv_t *priv = demuxer->priv;
  964|  1.01M|    while (priv->num_streams < priv->avfc->nb_streams)
  ------------------
  |  Branch (964:12): [True: 80.2k, False: 933k]
  ------------------
  965|  80.2k|        handle_new_stream(demuxer, priv->num_streams);
  966|   933k|}
demux_lavf.c:handle_new_stream:
  742|  80.2k|{
  743|  80.2k|    lavf_priv_t *priv = demuxer->priv;
  744|  80.2k|    AVFormatContext *avfc = priv->avfc;
  745|  80.2k|    AVStream *st = avfc->streams[i];
  746|  80.2k|    struct sh_stream *sh = NULL;
  747|  80.2k|    AVCodecParameters *codec = st->codecpar;
  748|  80.2k|    int lavc_delay = codec->initial_padding;
  749|       |
  750|  80.2k|    switch (codec->codec_type) {
  751|  28.1k|    case AVMEDIA_TYPE_AUDIO: {
  ------------------
  |  Branch (751:5): [True: 28.1k, False: 52.1k]
  ------------------
  752|  28.1k|        sh = demux_alloc_sh_stream(STREAM_AUDIO);
  753|  28.1k|        if (!mp_chmap_from_av_layout(&sh->codec->channels, &codec->ch_layout)) {
  ------------------
  |  Branch (753:13): [True: 71, False: 28.0k]
  ------------------
  754|     71|            char layout[128] = {0};
  755|     71|            MP_WARN(demuxer,
  ------------------
  |  |   90|     71|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    142|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 71]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  756|     71|                    "Failed to convert channel layout %s to mpv one!\n",
  757|     71|                    av_channel_layout_describe(&codec->ch_layout,
  758|     71|                                               layout, 128) < 0 ?
  759|     71|                    "undefined" : layout);
  760|     71|        }
  761|       |
  762|  28.1k|        sh->codec->samplerate = codec->sample_rate;
  763|  28.1k|        sh->codec->bitrate = codec->bit_rate;
  764|  28.1k|        sh->codec->format_name = talloc_strdup(sh->codec, av_get_sample_fmt_name(codec->format));
  ------------------
  |  |   50|  28.1k|#define talloc_strdup                   ta_xstrdup
  ------------------
  765|       |
  766|  28.1k|        double delay = 0;
  767|  28.1k|        if (codec->sample_rate > 0)
  ------------------
  |  Branch (767:13): [True: 2.40k, False: 25.7k]
  ------------------
  768|  2.40k|            delay = lavc_delay / (double)codec->sample_rate;
  769|  28.1k|        priv->seek_delay = MPMAX(priv->seek_delay, delay);
  ------------------
  |  |   44|  28.1k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 28.1k]
  |  |  ------------------
  ------------------
  770|       |
  771|  28.1k|        export_replaygain(demuxer, sh, st);
  772|       |
  773|  28.1k|        sh->seek_preroll = delay;
  774|       |
  775|  28.1k|        break;
  776|      0|    }
  777|  45.3k|    case AVMEDIA_TYPE_VIDEO: {
  ------------------
  |  Branch (777:5): [True: 45.3k, False: 34.9k]
  ------------------
  778|  45.3k|        sh = demux_alloc_sh_stream(STREAM_VIDEO);
  779|       |
  780|  45.3k|        if ((st->disposition & AV_DISPOSITION_ATTACHED_PIC) &&
  ------------------
  |  Branch (780:13): [True: 0, False: 45.3k]
  ------------------
  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|  45.3k|        if (!sh->attached_picture) {
  ------------------
  |  Branch (792:13): [True: 45.3k, False: 0]
  ------------------
  793|       |            // A real video stream probably means it's a packet based format.
  794|  45.3k|            priv->pcm_seek_hack_disabled = true;
  795|  45.3k|            priv->pcm_seek_hack = NULL;
  796|       |            // Also, we don't want to do this shit for ogv videos.
  797|  45.3k|            if (priv->linearize_ts < 0)
  ------------------
  |  Branch (797:17): [True: 0, False: 45.3k]
  ------------------
  798|      0|                priv->linearize_ts = 0;
  799|  45.3k|        }
  800|       |
  801|  45.3k|        sh->codec->disp_w = codec->width;
  802|  45.3k|        sh->codec->disp_h = codec->height;
  803|  45.3k|        sh->codec->bitrate = codec->bit_rate;
  804|  45.3k|        sh->codec->format_name = talloc_strdup(sh->codec, av_get_pix_fmt_name(codec->format));
  ------------------
  |  |   50|  45.3k|#define talloc_strdup                   ta_xstrdup
  ------------------
  805|  45.3k|        if (st->avg_frame_rate.num)
  ------------------
  |  Branch (805:13): [True: 42.7k, False: 2.53k]
  ------------------
  806|  42.7k|            sh->codec->fps = av_q2d(st->avg_frame_rate);
  807|  45.3k|        if (is_image(st, sh->attached_picture, priv->avif)) {
  ------------------
  |  Branch (807:13): [True: 4.75k, False: 40.5k]
  ------------------
  808|  4.75k|            MP_VERBOSE(demuxer, "Assuming this is an image format.\n");
  ------------------
  |  |   92|  4.75k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.75k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  809|  4.75k|            sh->image = true;
  810|  4.75k|            sh->codec->fps = demuxer->opts->mf_fps;
  811|  4.75k|        }
  812|  45.3k|        sh->codec->par_w = st->sample_aspect_ratio.num;
  813|  45.3k|        sh->codec->par_h = st->sample_aspect_ratio.den;
  814|       |
  815|  45.3k|        const uint8_t *sd = mp_av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX);
  816|  45.3k|        if (sd) {
  ------------------
  |  Branch (816:13): [True: 0, False: 45.3k]
  ------------------
  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|  45.3k|        if ((sd = mp_av_stream_get_side_data(st, AV_PKT_DATA_STEREO3D)))
  ------------------
  |  Branch (822:13): [True: 356, False: 44.9k]
  ------------------
  823|    356|            sh->codec->stereo_mode = mp_stereo3d_from_av((const AVStereo3D *)sd);
  824|       |
  825|  45.3k|        if ((sd = mp_av_stream_get_side_data(st, AV_PKT_DATA_DOVI_CONF))) {
  ------------------
  |  Branch (825:13): [True: 0, False: 45.3k]
  ------------------
  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|  45.3k|        sh->codec->avi_dts = matches_avinputformat_name(priv, "avi");
  837|       |
  838|  45.3k|        break;
  839|      0|    }
  840|  6.69k|    case AVMEDIA_TYPE_SUBTITLE: {
  ------------------
  |  Branch (840:5): [True: 6.69k, False: 73.5k]
  ------------------
  841|  6.69k|        sh = demux_alloc_sh_stream(STREAM_SUB);
  842|       |
  843|  6.69k|        if (codec->extradata_size) {
  ------------------
  |  Branch (843:13): [True: 1.06k, False: 5.63k]
  ------------------
  844|  1.06k|            sh->codec->extradata = talloc_size(sh->codec, codec->extradata_size);
  ------------------
  |  |   43|  1.06k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  1.06k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  1.06k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.06k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.06k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.06k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|  1.06k|            memcpy(sh->codec->extradata, codec->extradata, codec->extradata_size);
  846|  1.06k|            sh->codec->extradata_size = codec->extradata_size;
  847|  1.06k|        }
  848|       |
  849|  6.69k|        if (matches_avinputformat_name(priv, "microdvd")) {
  ------------------
  |  Branch (849:13): [True: 0, False: 6.69k]
  ------------------
  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|  6.69k|        break;
  858|      0|    }
  859|      0|    case AVMEDIA_TYPE_ATTACHMENT: {
  ------------------
  |  Branch (859:5): [True: 0, False: 80.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|    122|    default: ;
  ------------------
  |  Branch (870:5): [True: 122, False: 80.1k]
  ------------------
  871|  80.2k|    }
  872|       |
  873|  80.2k|    struct stream_info *info = talloc_zero(priv, struct stream_info);
  ------------------
  |  |   27|  80.2k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  80.2k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  80.2k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|  80.2k|    *info = (struct stream_info){
  875|  80.2k|        .sh = sh,
  876|  80.2k|        .last_key_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  80.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  877|  80.2k|        .highest_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  80.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  878|  80.2k|    };
  879|  80.2k|    mp_assert(priv->num_streams == i); // directly mapped
  ------------------
  |  |   41|  80.2k|#define mp_assert assert
  ------------------
  |  Branch (879:5): [True: 80.2k, False: 0]
  ------------------
  880|  80.2k|    MP_TARRAY_APPEND(priv, priv->streams, priv->num_streams, info);
  ------------------
  |  |  105|  80.2k|    do {                                            \
  |  |  106|  80.2k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  80.2k|    do {                                            \
  |  |  |  |   97|  80.2k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  80.2k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  80.2k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  80.2k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 58.3k, False: 21.8k]
  |  |  |  |  ------------------
  |  |  |  |   99|  80.2k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  58.3k|    do {                                                        \
  |  |  |  |  |  |   89|  58.3k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  58.3k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  58.3k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  58.3k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  58.3k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  58.3k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  58.3k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 58.3k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  80.2k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 80.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  80.2k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  80.2k|        (idxvar)++;                                 \
  |  |  109|  80.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 80.2k]
  |  |  ------------------
  ------------------
  881|       |
  882|  80.2k|    if (sh) {
  ------------------
  |  Branch (882:9): [True: 80.1k, False: 122]
  ------------------
  883|  80.1k|        sh->ff_index = st->index;
  884|  80.1k|        mp_codec_info_from_avcodecpar(codec, sh->codec);
  885|  80.1k|        sh->codec->codec_tag = codec->codec_tag;
  886|  80.1k|        AVCodecParameters **lavp = talloc_ptrtype(sh->codec, lavp);
  ------------------
  |  |   34|  80.1k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  80.1k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  80.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|  80.1k|        talloc_set_destructor(lavp, avcodec_par_destructor);
  ------------------
  |  |   41|  80.1k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  888|  80.1k|        *lavp = avcodec_parameters_alloc();
  889|  80.1k|        if (*lavp && avcodec_parameters_copy(*lavp, codec) >= 0)
  ------------------
  |  Branch (889:13): [True: 80.1k, False: 0]
  |  Branch (889:22): [True: 80.1k, False: 0]
  ------------------
  890|  80.1k|            sh->codec->lav_codecpar = *lavp;
  891|  80.1k|        sh->codec->native_tb_num = st->time_base.num;
  892|  80.1k|        sh->codec->native_tb_den = st->time_base.den;
  893|  80.1k|        sh->codec->duration = st->duration * av_q2d(st->time_base);
  894|       |
  895|  80.1k|        if (st->disposition & AV_DISPOSITION_DEFAULT)
  ------------------
  |  Branch (895:13): [True: 215, False: 79.9k]
  ------------------
  896|    215|            sh->default_track = true;
  897|  80.1k|        if (st->disposition & AV_DISPOSITION_FORCED)
  ------------------
  |  Branch (897:13): [True: 0, False: 80.1k]
  ------------------
  898|      0|            sh->forced_track = true;
  899|  80.1k|        if (st->disposition & AV_DISPOSITION_DEPENDENT)
  ------------------
  |  Branch (899:13): [True: 0, False: 80.1k]
  ------------------
  900|      0|            sh->dependent_track = true;
  901|  80.1k|        if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
  ------------------
  |  Branch (901:13): [True: 70, False: 80.0k]
  ------------------
  902|     70|            sh->visual_impaired_track = true;
  903|  80.1k|        if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
  ------------------
  |  Branch (903:13): [True: 512, False: 79.6k]
  ------------------
  904|    512|            sh->hearing_impaired_track = true;
  905|  80.1k|        if (st->disposition & AV_DISPOSITION_ORIGINAL)
  ------------------
  |  Branch (905:13): [True: 0, False: 80.1k]
  ------------------
  906|      0|            sh->original_track = true;
  907|  80.1k|        if (st->disposition & AV_DISPOSITION_COMMENT)
  ------------------
  |  Branch (907:13): [True: 31, False: 80.0k]
  ------------------
  908|     31|            sh->commentary_track = true;
  909|  80.1k|        if (st->disposition & AV_DISPOSITION_STILL_IMAGE)
  ------------------
  |  Branch (909:13): [True: 0, False: 80.1k]
  ------------------
  910|      0|            sh->still_image = true;
  911|  80.1k|        if (priv->format_hack.use_stream_ids)
  ------------------
  |  Branch (911:13): [True: 29.9k, False: 50.1k]
  ------------------
  912|  29.9k|            sh->demuxer_id = st->id;
  913|  80.1k|        AVDictionaryEntry *title = av_dict_get(st->metadata, "title", NULL, 0);
  914|  80.1k|        if (title && title->value)
  ------------------
  |  Branch (914:13): [True: 16, False: 80.1k]
  |  Branch (914:22): [True: 16, False: 0]
  ------------------
  915|     16|            sh->title = talloc_strdup(sh, title->value);
  ------------------
  |  |   50|     16|#define talloc_strdup                   ta_xstrdup
  ------------------
  916|  80.1k|        AVDictionaryEntry *comment = av_dict_get(st->metadata, "comment", NULL, 0);
  917|  80.1k|        if (!sh->title && comment && comment->value)
  ------------------
  |  Branch (917:13): [True: 80.1k, False: 16]
  |  Branch (917:27): [True: 0, False: 80.1k]
  |  Branch (917:38): [True: 0, False: 0]
  ------------------
  918|      0|            sh->title = talloc_strdup(sh, comment->value);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  919|  80.1k|        AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
  920|  80.1k|        if (lang && lang->value && strcmp(lang->value, "und") != 0)
  ------------------
  |  Branch (920:13): [True: 22.0k, False: 58.0k]
  |  Branch (920:21): [True: 22.0k, False: 0]
  |  Branch (920:36): [True: 22.0k, False: 0]
  ------------------
  921|  22.0k|            sh->lang = talloc_strdup(sh, lang->value);
  ------------------
  |  |   50|  22.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
  922|  80.1k|        sh->hls_bitrate = dict_get_decimal(st->metadata, "variant_bitrate", 0);
  923|  80.1k|        AVProgram *prog = NULL;
  924|       |        // In the order as reported by lavf
  925|  80.1k|        while ((prog = av_find_program_from_stream(avfc, prog, i)))
  ------------------
  |  Branch (925:16): [True: 0, False: 80.1k]
  ------------------
  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|  80.1k|        sh->missing_timestamps = !!(priv->avif_flags & AVFMT_NOTIMESTAMPS);
  928|  80.1k|        mp_tags_move_from_av_dictionary(sh->tags, &st->metadata);
  929|  80.1k|        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|  80.1k|        if (priv->is_dvd && sh->type == STREAM_SUB)
  ------------------
  |  Branch (934:13): [True: 0, False: 80.1k]
  |  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|  80.1k|        if (sh->codec->codec && strncmp(sh->codec->codec, "pcm_", 4) == 0 &&
  ------------------
  |  Branch (942:13): [True: 80.1k, False: 0]
  |  Branch (942:33): [True: 74, False: 80.0k]
  ------------------
  943|     74|            codec->block_align && !priv->pcm_seek_hack_disabled &&
  ------------------
  |  Branch (943:13): [True: 0, False: 74]
  |  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|  80.1k|    }
  956|       |
  957|  80.2k|    select_tracks(demuxer, i);
  958|  80.2k|}
demux_lavf.c:export_replaygain:
  672|  28.1k|{
  673|  28.1k|    const AVReplayGain *av_rgain =
  674|  28.1k|        (const AVReplayGain *)mp_av_stream_get_side_data(st, AV_PKT_DATA_REPLAYGAIN);
  675|  28.1k|    if (!av_rgain)
  ------------------
  |  Branch (675:9): [True: 28.1k, False: 0]
  ------------------
  676|  28.1k|        return;
  677|       |
  678|  28.1k|    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|  45.3k|{
  728|  45.3k|    return st->nb_frames <= 1 && (
  ------------------
  |  Branch (728:12): [True: 45.3k, False: 7]
  ------------------
  729|  45.3k|        attached_picture ||
  ------------------
  |  Branch (729:9): [True: 0, False: 45.3k]
  ------------------
  730|  45.3k|        bstr_endswith0(bstr0(avif->name), "_pipe") ||
  ------------------
  |  Branch (730:9): [True: 4.74k, False: 40.5k]
  ------------------
  731|  40.5k|        strcmp(avif->name, "alias_pix") == 0 ||
  ------------------
  |  Branch (731:9): [True: 2, False: 40.5k]
  ------------------
  732|  40.5k|        strcmp(avif->name, "gif") == 0 ||
  ------------------
  |  Branch (732:9): [True: 0, False: 40.5k]
  ------------------
  733|  40.5k|        strcmp(avif->name, "ico") == 0 ||
  ------------------
  |  Branch (733:9): [True: 0, False: 40.5k]
  ------------------
  734|  40.5k|        strcmp(avif->name, "image2pipe") == 0 ||
  ------------------
  |  Branch (734:9): [True: 0, False: 40.5k]
  ------------------
  735|  40.5k|        ((st->codecpar->codec_id == AV_CODEC_ID_HEVC ||
  ------------------
  |  Branch (735:11): [True: 0, False: 40.5k]
  ------------------
  736|  40.5k|          st->codecpar->codec_id == AV_CODEC_ID_AV1)
  ------------------
  |  Branch (736:11): [True: 89, False: 40.4k]
  ------------------
  737|     89|         && st->nb_frames == 1)
  ------------------
  |  Branch (737:13): [True: 2, False: 87]
  ------------------
  738|  45.3k|    );
  739|  45.3k|}
demux_lavf.c:mp_av_stream_get_side_data:
  662|   164k|{
  663|   164k|    const AVPacketSideData *sd;
  664|   164k|    sd = av_packet_side_data_get(st->codecpar->coded_side_data,
  665|   164k|                                 st->codecpar->nb_coded_side_data,
  666|   164k|                                 type);
  667|   164k|    return sd ? sd->data : NULL;
  ------------------
  |  Branch (667:12): [True: 356, False: 163k]
  ------------------
  668|   164k|}
demux_lavf.c:avcodec_par_destructor:
   73|  80.1k|{
   74|  80.1k|    avcodec_parameters_free(p);
   75|  80.1k|}
demux_lavf.c:dict_get_decimal:
  715|  80.1k|{
  716|  80.1k|    AVDictionaryEntry *e = av_dict_get(dict, entry, NULL, 0);
  717|  80.1k|    if (e && e->value) {
  ------------------
  |  Branch (717:9): [True: 0, False: 80.1k]
  |  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|  80.1k|    return def;
  724|  80.1k|}
demux_lavf.c:select_tracks:
  643|   119k|{
  644|   119k|    lavf_priv_t *priv = demuxer->priv;
  645|   239k|    for (int n = start; n < priv->num_streams; n++) {
  ------------------
  |  Branch (645:25): [True: 119k, False: 119k]
  ------------------
  646|   119k|        struct sh_stream *stream = priv->streams[n]->sh;
  647|   119k|        AVStream *st = priv->avfc->streams[n];
  648|   119k|        bool selected = stream && demux_stream_is_selected(stream) &&
  ------------------
  |  Branch (648:25): [True: 119k, False: 121]
  |  Branch (648:35): [True: 39.2k, False: 80.5k]
  ------------------
  649|  39.1k|                        !stream->attached_picture;
  ------------------
  |  Branch (649:25): [True: 39.1k, False: 0]
  ------------------
  650|   119k|        if (!selected && priv->streams[n]->dovi_split) {
  ------------------
  |  Branch (650:13): [True: 80.6k, False: 39.2k]
  |  Branch (650:26): [True: 0, False: 80.6k]
  ------------------
  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|   119k|        st->discard = selected ? AVDISCARD_DEFAULT : AVDISCARD_ALL;
  ------------------
  |  Branch (656:23): [True: 39.1k, False: 80.6k]
  ------------------
  657|   119k|    }
  658|   119k|}
demux_lavf.c:build_editions:
 1073|  56.9k|{
 1074|  56.9k|    lavf_priv_t *priv = demuxer->priv;
 1075|  56.9k|    AVFormatContext *avfc = priv->avfc;
 1076|       |
 1077|  56.9k|    if (avfc->nb_programs <= 1)
  ------------------
  |  Branch (1077:9): [True: 56.9k, False: 0]
  ------------------
 1078|  56.9k|        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|  56.9k|{
 1400|  56.9k|    lavf_priv_t *priv = demuxer->priv;
 1401|  56.9k|    AVFormatContext *avfc = priv->avfc;
 1402|       |
 1403|  56.9k|    for (unsigned i = 0; i < avfc->nb_stream_groups; i++) {
  ------------------
  |  Branch (1403:26): [True: 0, False: 56.9k]
  ------------------
 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|  56.9k|}
demux_lavf.c:detect_dovi_split_streams:
 1445|  56.9k|{
 1446|  56.9k|    lavf_priv_t *priv = demuxer->priv;
 1447|  56.9k|    int snapshot_count = priv->num_streams;
 1448|   137k|    for (int n = 0; n < snapshot_count; n++) {
  ------------------
  |  Branch (1448:21): [True: 80.1k, False: 56.9k]
  ------------------
 1449|  80.1k|        struct stream_info *info = priv->streams[n];
 1450|  80.1k|        struct sh_stream *sh = info ? info->sh : NULL;
  ------------------
  |  Branch (1450:32): [True: 80.1k, False: 0]
  ------------------
 1451|  80.1k|        if (!sh || sh->type != STREAM_VIDEO || !sh->codec ||
  ------------------
  |  Branch (1451:13): [True: 122, False: 80.0k]
  |  Branch (1451:20): [True: 34.7k, False: 45.2k]
  |  Branch (1451:48): [True: 0, False: 45.2k]
  ------------------
 1452|  45.2k|            !sh->codec->dv_el_present || sh->group)
  ------------------
  |  Branch (1452:13): [True: 45.2k, False: 0]
  |  Branch (1452:42): [True: 0, False: 0]
  ------------------
 1453|  80.1k|        {
 1454|  80.1k|            continue;
 1455|  80.1k|        }
 1456|      0|        info->dovi_split = mp_dovi_split_create(demuxer, sh);
 1457|      0|    }
 1458|  56.9k|}
demux_lavf.c:demux_lavf_read_packet:
 1755|   915k|{
 1756|   915k|    lavf_priv_t *priv = demux->priv;
 1757|       |
 1758|       |    // Companion EL packet queued by the Dolby Vision splitter on a prior call.
 1759|   915k|    if (priv->pending_pkt) {
  ------------------
  |  Branch (1759:9): [True: 0, False: 915k]
  ------------------
 1760|      0|        *mp_pkt = priv->pending_pkt;
 1761|      0|        priv->pending_pkt = NULL;
 1762|      0|        return true;
 1763|      0|    }
 1764|       |
 1765|   915k|    AVPacket *pkt = av_packet_alloc();
 1766|   915k|    MP_HANDLE_OOM(pkt);
  ------------------
  |  |  206|   915k|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|   915k|        void *oom_p_ = (x);     \
  |  |  208|   915k|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 915k]
  |  |  ------------------
  |  |  209|   915k|            abort();            \
  |  |  210|   915k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 915k]
  |  |  ------------------
  ------------------
 1767|   915k|    int r = av_read_frame(priv->avfc, pkt);
 1768|   915k|    update_read_stats(demux);
 1769|   915k|    if (r < 0) {
  ------------------
  |  Branch (1769:9): [True: 39.1k, False: 876k]
  ------------------
 1770|  39.1k|        av_packet_free(&pkt);
 1771|  39.1k|        if (r == AVERROR_EOF)
  ------------------
  |  Branch (1771:13): [True: 39.1k, False: 1]
  ------------------
 1772|  39.1k|            return false;
 1773|      1|        if (demux_read_interrupted(demux)) {
  ------------------
  |  Branch (1773:13): [True: 0, False: 1]
  ------------------
 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|      1|        MP_WARN(demux, "error reading packet: %s.\n", av_err2str(r));
  ------------------
  |  |   90|      1|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1778|      1|        if (priv->retry_counter >= 10) {
  ------------------
  |  Branch (1778:13): [True: 0, False: 1]
  ------------------
 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|      1|        priv->retry_counter += 1;
 1783|      1|        return true;
 1784|      1|    }
 1785|   876k|    priv->retry_counter = 0;
 1786|       |
 1787|   876k|    add_new_streams(demux);
 1788|   876k|    update_metadata(demux);
 1789|       |
 1790|   876k|    mp_assert(pkt->stream_index >= 0 && pkt->stream_index < priv->num_streams);
  ------------------
  |  |   41|   876k|#define mp_assert assert
  ------------------
  |  Branch (1790:5): [True: 876k, False: 17]
  |  Branch (1790:5): [True: 876k, False: 1]
  ------------------
 1791|   876k|    struct stream_info *info = priv->streams[pkt->stream_index];
 1792|   876k|    struct sh_stream *stream = info->sh;
 1793|   876k|    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|   876k|    struct sh_stream *split_el = info->dovi_split
  ------------------
  |  Branch (1798:34): [True: 0, False: 876k]
  ------------------
 1799|   876k|                                    ? mp_dovi_split_el_stream(info->dovi_split)
 1800|   876k|                                    : NULL;
 1801|   876k|    bool need_for_split = split_el && demux_stream_is_selected(split_el);
  ------------------
  |  Branch (1801:27): [True: 0, False: 876k]
  |  Branch (1801:39): [True: 0, False: 0]
  ------------------
 1802|   876k|    if (!demux_stream_is_selected(stream) && !need_for_split) {
  ------------------
  |  Branch (1802:9): [True: 611, False: 875k]
  |  Branch (1802:46): [True: 611, False: 0]
  ------------------
 1803|    611|        av_packet_free(&pkt);
 1804|    611|        return true; // don't signal EOF if skipping a packet
 1805|    611|    }
 1806|       |
 1807|       |    // Never send additional frames for streams that are a single frame.
 1808|   875k|    if (stream->image && priv->format_hack.first_frame_only && pkt->pos != 0) {
  ------------------
  |  Branch (1808:9): [True: 0, False: 875k]
  |  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|   875k|    struct demux_packet *dp = new_demux_packet_from_avpacket(demux->packet_pool, pkt);
 1814|   875k|    if (!dp) {
  ------------------
  |  Branch (1814:9): [True: 0, False: 875k]
  ------------------
 1815|      0|        av_packet_free(&pkt);
 1816|      0|        return true;
 1817|      0|    }
 1818|       |
 1819|   875k|    if (priv->pcm_seek_hack == st && !priv->pcm_seek_hack_packet_size)
  ------------------
  |  Branch (1819:9): [True: 0, False: 875k]
  |  Branch (1819:38): [True: 0, False: 0]
  ------------------
 1820|      0|        priv->pcm_seek_hack_packet_size = pkt->size;
 1821|       |
 1822|   875k|    dp->pts = mp_pts_from_av(pkt->pts, &st->time_base);
 1823|   875k|    dp->dts = mp_pts_from_av(pkt->dts, &st->time_base);
 1824|   875k|    dp->duration = pkt->duration * av_q2d(st->time_base);
 1825|   875k|    dp->pos = pkt->pos;
 1826|   875k|    dp->keyframe = pkt->flags & AV_PKT_FLAG_KEY;
 1827|   875k|    dp->is_wrapped_avframe = st->codecpar->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME;
 1828|   875k|    if (dp->is_wrapped_avframe) {
  ------------------
  |  Branch (1828:9): [True: 812k, False: 63.0k]
  ------------------
 1829|   812k|        mp_require(dp->buffer);
  ------------------
  |  |   42|   812k|#define mp_require assert
  ------------------
  |  Branch (1829:9): [True: 812k, False: 0]
  ------------------
 1830|   812k|        const AVFrame *frame = (AVFrame *)dp->buffer;
 1831|   812k|        dp->keyframe |= frame->flags & AV_FRAME_FLAG_KEY;
 1832|   812k|    }
 1833|   875k|    av_packet_free(&pkt);
 1834|       |
 1835|   875k|    if (priv->format_hack.clear_filepos)
  ------------------
  |  Branch (1835:9): [True: 0, False: 875k]
  ------------------
 1836|      0|        dp->pos = -1;
 1837|       |
 1838|   875k|    dp->stream = stream->index;
 1839|       |
 1840|   875k|    if (priv->linearize_ts) {
  ------------------
  |  Branch (1840:9): [True: 0, False: 875k]
  ------------------
 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|   875k|    if (info->dovi_split) {
  ------------------
  |  Branch (1865:9): [True: 0, False: 875k]
  ------------------
 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|   875k|    if (st->event_flags & AVSTREAM_EVENT_FLAG_METADATA_UPDATED) {
  ------------------
  |  Branch (1871:9): [True: 0, False: 875k]
  ------------------
 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|   875k|    *mp_pkt = dp;
 1880|       |    return true;
 1881|   875k|}
demux_lavf.c:update_read_stats:
  287|   922k|{
  288|   922k|    lavf_priv_t *priv = demuxer->priv;
  289|       |
  290|   922k|    for (int n = 0; n < priv->num_nested; n++) {
  ------------------
  |  Branch (290:21): [True: 0, False: 922k]
  ------------------
  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|   922k|}
demux_lavf.c:update_metadata:
  969|   876k|{
  970|   876k|    lavf_priv_t *priv = demuxer->priv;
  971|   876k|    if (priv->avfc->event_flags & AVFMT_EVENT_FLAG_METADATA_UPDATED) {
  ------------------
  |  Branch (971:9): [True: 0, False: 876k]
  ------------------
  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|   876k|}
demux_lavf.c:reset_dovi_split_state:
 1884|  6.68k|{
 1885|  6.68k|    lavf_priv_t *priv = demuxer->priv;
 1886|  6.68k|    TA_FREEP(&priv->pending_pkt);
  ------------------
  |  |   81|  6.68k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  6.68k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 6.68k]
  |  |  ------------------
  ------------------
 1887|  13.7k|    for (int n = 0; n < priv->num_streams; n++) {
  ------------------
  |  Branch (1887:21): [True: 7.05k, False: 6.68k]
  ------------------
 1888|  7.05k|        if (priv->streams[n] && priv->streams[n]->dovi_split)
  ------------------
  |  Branch (1888:13): [True: 7.05k, False: 0]
  |  Branch (1888:33): [True: 0, False: 7.05k]
  ------------------
 1889|      0|            mp_dovi_split_reset(priv->streams[n]->dovi_split);
 1890|  7.05k|    }
 1891|  6.68k|}
demux_lavf.c:demux_close_lavf:
 2008|  71.9k|{
 2009|  71.9k|    lavf_priv_t *priv = demuxer->priv;
 2010|  71.9k|    if (priv) {
  ------------------
  |  Branch (2010:9): [True: 71.9k, False: 2]
  ------------------
 2011|       |        // This will be a dangling pointer; but see below.
 2012|  71.9k|        AVIOContext *leaking = priv->avfc ? priv->avfc->pb : NULL;
  ------------------
  |  Branch (2012:32): [True: 58.3k, False: 13.6k]
  ------------------
 2013|  71.9k|        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|  71.9k|        if (priv->num_nested == 1 && priv->nested[0].id == leaking)
  ------------------
  |  Branch (2018:13): [True: 0, False: 71.9k]
  |  Branch (2018:38): [True: 0, False: 0]
  ------------------
 2019|      0|            priv->num_nested = 0;
 2020|  71.9k|        if (priv->num_nested) {
  ------------------
  |  Branch (2020:13): [True: 0, False: 71.9k]
  ------------------
 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|  71.9k|        if (priv->pb)
  ------------------
  |  Branch (2024:13): [True: 27.5k, False: 44.4k]
  ------------------
 2025|  27.5k|            av_freep(&priv->pb->buffer);
 2026|  71.9k|        av_freep(&priv->pb);
 2027|   152k|        for (int n = 0; n < priv->num_streams; n++) {
  ------------------
  |  Branch (2027:25): [True: 80.2k, False: 71.9k]
  ------------------
 2028|  80.2k|            struct stream_info *info = priv->streams[n];
 2029|  80.2k|            TA_FREEP(&info->dovi_split);
  ------------------
  |  |   81|  80.2k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  80.2k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 80.2k]
  |  |  ------------------
  ------------------
 2030|  80.2k|        }
 2031|  71.9k|        TA_FREEP(&priv->pending_pkt);
  ------------------
  |  |   81|  71.9k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  71.9k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 71.9k]
  |  |  ------------------
  ------------------
 2032|  71.9k|        if (priv->own_stream)
  ------------------
  |  Branch (2032:13): [True: 360, False: 71.6k]
  ------------------
 2033|    360|            free_stream(priv->stream);
 2034|  71.9k|        if (priv->av_opts)
  ------------------
  |  Branch (2034:13): [True: 32.5k, False: 39.4k]
  ------------------
 2035|  32.5k|            av_dict_free(&priv->av_opts);
 2036|  71.9k|        talloc_free(priv);
  ------------------
  |  |   47|  71.9k|#define talloc_free                     ta_free
  ------------------
 2037|       |        demuxer->priv = NULL;
 2038|  71.9k|    }
 2039|  71.9k|}
demux_lavf.c:demux_seek_lavf:
 1916|  6.68k|{
 1917|  6.68k|    lavf_priv_t *priv = demuxer->priv;
 1918|  6.68k|    int avsflags = 0;
 1919|  6.68k|    int64_t seek_pts_av = 0;
 1920|  6.68k|    int seek_stream = -1;
 1921|       |
 1922|  6.68k|    if (priv->any_ts_fixed)  {
  ------------------
  |  Branch (1922:9): [True: 0, False: 6.68k]
  ------------------
 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|  6.68k|    if (priv->linearize_ts < 0)
  ------------------
  |  Branch (1930:9): [True: 0, False: 6.68k]
  ------------------
 1931|      0|        priv->linearize_ts = 0;
 1932|       |
 1933|  6.68k|    if (!(flags & SEEK_FORWARD))
  ------------------
  |  |   95|  6.68k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (1933:9): [True: 6.68k, False: 0]
  ------------------
 1934|  6.68k|        avsflags = AVSEEK_FLAG_BACKWARD;
 1935|       |
 1936|  6.68k|    if (flags & SEEK_FACTOR) {
  ------------------
  |  |   94|  6.68k|#define SEEK_FACTOR   (1 << 1)      // argument is in range [0,1]
  ------------------
  |  Branch (1936:9): [True: 0, False: 6.68k]
  ------------------
 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|  6.68k|    } else {
 1950|  6.68k|        if (!(flags & SEEK_FORWARD))
  ------------------
  |  |   95|  6.68k|#define SEEK_FORWARD  (1 << 2)      // prefer later time if not exact
  ------------------
  |  Branch (1950:13): [True: 6.68k, False: 0]
  ------------------
 1951|  6.68k|            seek_pts -= priv->seek_delay;
 1952|  6.68k|        seek_pts_av = MPCLAMP(seek_pts, INT64_MIN / AV_TIME_BASE,
  ------------------
  |  |   46|  6.68k|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 6.68k]
  |  |  |  Branch (46:56): [True: 0, False: 6.68k]
  |  |  ------------------
  ------------------
 1953|  6.68k|                              INT64_MAX / AV_TIME_BASE) * AV_TIME_BASE;
 1954|  6.68k|    }
 1955|       |
 1956|       |    // Hack to make wav seeking "deterministic". Without this, features like
 1957|       |    // backward playback won't work.
 1958|  6.68k|    if (priv->pcm_seek_hack && !priv->pcm_seek_hack_packet_size) {
  ------------------
  |  Branch (1958:9): [True: 0, False: 6.68k]
  |  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|  6.68k|    if (priv->pcm_seek_hack && priv->pcm_seek_hack_packet_size &&
  ------------------
  |  Branch (1968:9): [True: 0, False: 6.68k]
  |  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|  6.68k|    int r = av_seek_frame(priv->avfc, seek_stream, seek_pts_av, avsflags);
 1984|  6.68k|    if (r < 0 && (avsflags & AVSEEK_FLAG_BACKWARD)) {
  ------------------
  |  Branch (1984:9): [True: 5.63k, False: 1.05k]
  |  Branch (1984:18): [True: 5.63k, False: 0]
  ------------------
 1985|       |        // When seeking before the beginning of the file, and seeking fails,
 1986|       |        // try again without the backwards flag to make it seek to the
 1987|       |        // beginning.
 1988|  5.63k|        avsflags &= ~AVSEEK_FLAG_BACKWARD;
 1989|  5.63k|        r = av_seek_frame(priv->avfc, seek_stream, seek_pts_av, avsflags);
 1990|  5.63k|    }
 1991|       |
 1992|  6.68k|    if (r < 0) {
  ------------------
  |  Branch (1992:9): [True: 1.40k, False: 5.28k]
  ------------------
 1993|  1.40k|        char buf[180];
 1994|  1.40k|        av_strerror(r, buf, sizeof(buf));
 1995|  1.40k|        MP_VERBOSE(demuxer, "Seek failed (%s)\n", buf);
  ------------------
  |  |   92|  1.40k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.40k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1996|  1.40k|    }
 1997|  6.68k|    reset_dovi_split_state(demuxer);
 1998|       |
 1999|  6.68k|    update_read_stats(demuxer);
 2000|  6.68k|}
demux_lavf.c:demux_lavf_switched_tracks:
 2003|  39.2k|{
 2004|  39.2k|    select_tracks(demuxer, 0);
 2005|  39.2k|}

demux_mf.c:demux_open_mf:
  372|  15.0k|{
  373|  15.0k|    mf_t *mf;
  374|       |
  375|  15.0k|    if (strncmp(demuxer->stream->url, "mf://", 5) == 0 &&
  ------------------
  |  Branch (375:9): [True: 0, False: 15.0k]
  ------------------
  376|      0|        demuxer->stream->info && strcmp(demuxer->stream->info->name, "mf") == 0)
  ------------------
  |  Branch (376:9): [True: 0, False: 0]
  |  Branch (376:34): [True: 0, False: 0]
  ------------------
  377|      0|    {
  378|      0|        mf = open_mf_pattern(demuxer, demuxer, demuxer->stream->url + 5);
  379|  15.0k|    } else {
  380|  15.0k|        mf = open_mf_single(demuxer, demuxer->log, demuxer->stream->url);
  381|  15.0k|        int bog = 0;
  382|  15.0k|        MP_TARRAY_APPEND(mf, mf->streams, bog, demuxer->stream);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  383|  15.0k|    }
  384|       |
  385|  15.0k|    if (!mf || mf->nr_of_files < 1)
  ------------------
  |  Branch (385:9): [True: 0, False: 15.0k]
  |  Branch (385:16): [True: 0, False: 15.0k]
  ------------------
  386|      0|        goto error;
  387|       |
  388|  15.0k|    const char *codec = mp_map_mimetype_to_video_codec(demuxer->stream->mime_type);
  389|  15.0k|    if (!codec || (demuxer->opts->mf_type && demuxer->opts->mf_type[0]))
  ------------------
  |  Branch (389:9): [True: 15.0k, False: 0]
  |  Branch (389:20): [True: 0, False: 0]
  |  Branch (389:46): [True: 0, False: 0]
  ------------------
  390|  15.0k|        codec = probe_format(mf, demuxer->opts->mf_type, check);
  391|  15.0k|    if (!codec)
  ------------------
  |  Branch (391:9): [True: 15.0k, False: 0]
  ------------------
  392|  15.0k|        goto error;
  393|       |
  394|      0|    mf->curr_frame = 0;
  395|       |
  396|       |    // create a new video stream header
  397|      0|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
  398|      0|    if (mf->nr_of_files == 1) {
  ------------------
  |  Branch (398:9): [True: 0, False: 0]
  ------------------
  399|      0|        MP_VERBOSE(demuxer, "Assuming this is an image format.\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__)
  |  |  ------------------
  ------------------
  400|      0|        sh->image = true;
  401|      0|    }
  402|       |
  403|      0|    struct mp_codec_params *c = sh->codec;
  404|      0|    c->codec = codec;
  405|      0|    c->disp_w = 0;
  406|      0|    c->disp_h = 0;
  407|      0|    c->fps = demuxer->opts->mf_fps;
  408|      0|    c->reliable_fps = true;
  409|       |
  410|      0|    demux_add_sh_stream(demuxer, sh);
  411|       |
  412|      0|    mf->sh = sh;
  413|      0|    demuxer->priv = (void *)mf;
  414|      0|    demuxer->seekable = true;
  415|      0|    demuxer->duration = mf->nr_of_files / mf->sh->codec->fps;
  416|       |
  417|      0|    return 0;
  418|       |
  419|  15.0k|error:
  420|  15.0k|    return -1;
  421|  15.0k|}
demux_mf.c:mf_add:
   53|  15.0k|{
   54|  15.0k|    char *entry = talloc_strdup(mf, fname);
  ------------------
  |  |   50|  15.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
   55|  15.0k|    MP_TARRAY_APPEND(mf, mf->names, mf->nr_of_files, entry);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   56|  15.0k|}
demux_mf.c:open_mf_single:
  219|  15.0k|{
  220|  15.0k|    mf_t *mf = talloc_zero(talloc_ctx, mf_t);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  221|  15.0k|    mf->log = log;
  222|  15.0k|    mf_add(mf, filename);
  223|  15.0k|    return mf;
  224|  15.0k|}
demux_mf.c:probe_format:
  348|  15.0k|{
  349|  15.0k|    if (check > DEMUX_CHECK_REQUEST)
  ------------------
  |  Branch (349:9): [True: 7.50k, False: 7.50k]
  ------------------
  350|  7.50k|        return NULL;
  351|  7.50k|    char *org_type = type;
  352|  7.50k|    if (!type || !type[0]) {
  ------------------
  |  Branch (352:9): [True: 7.50k, False: 0]
  |  Branch (352:18): [True: 0, False: 0]
  ------------------
  353|  7.50k|        char *p = strrchr(mf->names[0], '.');
  354|  7.50k|        if (p)
  ------------------
  |  Branch (354:13): [True: 0, False: 7.50k]
  ------------------
  355|      0|            type = p + 1;
  356|  7.50k|    }
  357|   382k|    for (int i = 0; type2format[i].type; i++) {
  ------------------
  |  Branch (357:21): [True: 375k, False: 7.50k]
  ------------------
  358|   375k|        if (type && strcasecmp(type, type2format[i].type) == 0)
  ------------------
  |  Branch (358:13): [True: 0, False: 375k]
  |  Branch (358:21): [True: 0, False: 0]
  ------------------
  359|      0|            return type2format[i].codec;
  360|   375k|    }
  361|  7.50k|    if (check == DEMUX_CHECK_REQUEST) {
  ------------------
  |  Branch (361:9): [True: 0, False: 7.50k]
  ------------------
  362|      0|        if (!org_type) {
  ------------------
  |  Branch (362:13): [True: 0, False: 0]
  ------------------
  363|      0|            MP_ERR(mf, "file type was not set! (try --mf-type=ext)\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__)
  |  |  ------------------
  ------------------
  364|      0|        } 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|      0|    }
  368|       |    return NULL;
  369|  7.50k|}
demux_mf.c:demux_close_mf:
  424|  15.0k|{
  425|  15.0k|}

demux_mkv.c:demux_mkv_open:
 2510|  40.0k|{
 2511|  40.0k|    stream_t *s = demuxer->stream;
 2512|  40.0k|    mkv_demuxer_t *mkv_d;
 2513|  40.0k|    int64_t start_pos;
 2514|  40.0k|    int64_t end_pos;
 2515|       |
 2516|  40.0k|    mkv_d = talloc_zero(demuxer, struct mkv_demuxer);
  ------------------
  |  |   27|  40.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  40.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  40.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2517|  40.0k|    demuxer->priv = mkv_d;
 2518|  40.0k|    mkv_d->tc_scale = 1000000;
 2519|  40.0k|    mkv_d->a_skip_preroll = 1;
 2520|  40.0k|    mkv_d->skip_to_timecode = INT64_MIN;
 2521|       |
 2522|  40.0k|    if (demuxer->params)
  ------------------
  |  Branch (2522:9): [True: 40.0k, False: 0]
  ------------------
 2523|  40.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|  40.0k|    if (stream_read_peek(s, &(char[4]){0}, 4) != 4)
  ------------------
  |  Branch (2526:9): [True: 864, False: 39.1k]
  ------------------
 2527|    864|        return -1;
 2528|  39.1k|    if (!read_ebml_header(demuxer))
  ------------------
  |  Branch (2528:9): [True: 37.8k, False: 1.25k]
  ------------------
 2529|  37.8k|        return -1;
 2530|  1.25k|    MP_DBG(demuxer, "Found the head...\n");
  ------------------
  |  |   93|  1.25k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.25k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2531|       |
 2532|  1.25k|    if (!read_mkv_segment_header(demuxer, &end_pos))
  ------------------
  |  Branch (2532:9): [True: 577, False: 682]
  ------------------
 2533|    577|        return -1;
 2534|       |
 2535|    682|    mkv_d->segment_start = stream_tell(s);
 2536|    682|    mkv_d->segment_end = end_pos;
 2537|       |
 2538|    682|    struct MPOpts *mp_opts = mp_get_config_group(mkv_d, demuxer->global, &mp_opt_root);
 2539|    682|    mkv_d->edition_id = mp_opts->edition_id;
 2540|    682|    talloc_free(mp_opts);
  ------------------
  |  |   47|    682|#define talloc_free                     ta_free
  ------------------
 2541|       |
 2542|    682|    mkv_d->opts = mp_get_config_group(mkv_d, demuxer->global, &demux_mkv_conf);
 2543|       |
 2544|    682|    if (demuxer->params && demuxer->params->matroska_was_valid)
  ------------------
  |  Branch (2544:9): [True: 682, False: 0]
  |  Branch (2544:28): [True: 0, False: 682]
  ------------------
 2545|      0|        *demuxer->params->matroska_was_valid = true;
 2546|       |
 2547|  11.3k|    while (1) {
  ------------------
  |  Branch (2547:12): [True: 11.3k, Folded]
  ------------------
 2548|  11.3k|        start_pos = stream_tell(s);
 2549|  11.3k|        uint32_t id = ebml_read_id(s);
 2550|  11.3k|        if (s->eof) {
  ------------------
  |  Branch (2550:13): [True: 211, False: 11.1k]
  ------------------
 2551|    211|            if (!mkv_d->probably_webm_dash_init)
  ------------------
  |  Branch (2551:17): [True: 211, False: 0]
  ------------------
 2552|    211|                MP_WARN(demuxer, "Unexpected end of file (no clusters found)\n");
  ------------------
  |  |   90|    211|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    211|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2553|    211|            break;
 2554|    211|        }
 2555|  11.1k|        if (id == MATROSKA_ID_CLUSTER) {
  ------------------
  |  |   28|  11.1k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (2555:13): [True: 343, False: 10.8k]
  ------------------
 2556|    343|            MP_DBG(demuxer, "|+ found cluster\n");
  ------------------
  |  |   93|    343|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    343|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2557|    343|            mkv_d->first_cluster = start_pos;
 2558|    343|            mkv_d->cluster_start = start_pos;
 2559|    343|            break;
 2560|    343|        }
 2561|  10.8k|        int res = read_header_element(demuxer, id, start_pos);
 2562|  10.8k|        if (res < 0)
  ------------------
  |  Branch (2562:13): [True: 128, False: 10.7k]
  ------------------
 2563|    128|            return -1;
 2564|  10.8k|    }
 2565|       |
 2566|    554|    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|    554|    int only_cue = -1;
 2572|  1.97k|    for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (2572:21): [True: 1.42k, False: 554]
  ------------------
 2573|  1.42k|        struct header_elem *elem = &mkv_d->headers[n];
 2574|  1.42k|        if (elem->parsed)
  ------------------
  |  Branch (2574:13): [True: 1.26k, False: 159]
  ------------------
 2575|  1.26k|            continue;
 2576|       |        // Warn against incomplete files and skip headers outside of range.
 2577|    159|        if (elem->pos >= end || !s->seekable) {
  ------------------
  |  Branch (2577:13): [True: 22, False: 137]
  |  Branch (2577:33): [True: 0, False: 137]
  ------------------
 2578|     22|            elem->parsed = true; // don't bother if file is incomplete
 2579|     22|            if (end < 0 || !s->seekable) {
  ------------------
  |  Branch (2579:17): [True: 0, False: 22]
  |  Branch (2579:28): [True: 0, False: 22]
  ------------------
 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|     22|            } else if (!mkv_d->eof_warning &&
  ------------------
  |  Branch (2582:24): [True: 17, False: 5]
  ------------------
 2583|     17|                       !(mkv_d->probably_webm_dash_init &&  elem->pos == end))
  ------------------
  |  Branch (2583:26): [True: 0, False: 17]
  |  Branch (2583:61): [True: 0, False: 0]
  ------------------
 2584|     17|            {
 2585|     17|                MP_WARN(demuxer, "mkv metadata beyond end of file - incomplete "
  ------------------
  |  |   90|     17|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     17|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2586|     17|                        "file?\n");
 2587|     17|                mkv_d->eof_warning = true;
 2588|     17|            }
 2589|     22|            continue;
 2590|     22|        }
 2591|    137|        only_cue = only_cue < 0 && elem->id == MATROSKA_ID_CUES;
  ------------------
  |  |  130|    253|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (2591:20): [True: 116, False: 21]
  |  Branch (2591:36): [True: 0, False: 116]
  ------------------
 2592|    137|    }
 2593|       |
 2594|       |    // If there's only 1 needed element, and it's the cues, defer reading.
 2595|    554|    if (only_cue == 1) {
  ------------------
  |  Branch (2595:9): [True: 0, False: 554]
  ------------------
 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|    554|    } else {
 2599|       |        // Read them by ascending position to reduce unneeded seeks.
 2600|       |        // O(n^2) because the number of elements is very low.
 2601|    682|        while (1) {
  ------------------
  |  Branch (2601:16): [True: 682, Folded]
  ------------------
 2602|    682|            struct header_elem *lowest = NULL;
 2603|  2.48k|            for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (2603:29): [True: 1.80k, False: 682]
  ------------------
 2604|  1.80k|                struct header_elem *elem = &mkv_d->headers[n];
 2605|  1.80k|                if (elem->parsed)
  ------------------
  |  Branch (2605:21): [True: 1.64k, False: 159]
  ------------------
 2606|  1.64k|                    continue;
 2607|    159|                if (!lowest || elem->pos < lowest->pos)
  ------------------
  |  Branch (2607:21): [True: 137, False: 22]
  |  Branch (2607:32): [True: 2, False: 20]
  ------------------
 2608|    139|                    lowest = elem;
 2609|    159|            }
 2610|       |
 2611|    682|            if (!lowest)
  ------------------
  |  Branch (2611:17): [True: 545, False: 137]
  ------------------
 2612|    545|                break;
 2613|       |
 2614|    137|            if (read_deferred_element(demuxer, lowest) < 0)
  ------------------
  |  Branch (2614:17): [True: 9, False: 128]
  ------------------
 2615|      9|                return -1;
 2616|    137|        }
 2617|    554|    }
 2618|       |
 2619|    545|    if (!stream_seek(s, start_pos)) {
  ------------------
  |  Branch (2619:9): [True: 0, False: 545]
  ------------------
 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|    545|    MP_VERBOSE(demuxer, "All headers are parsed!\n");
  ------------------
  |  |   92|    545|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    545|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2625|       |
 2626|    545|    display_create_tracks(demuxer);
 2627|    545|    pair_dovi_tracks(demuxer);
 2628|    545|    add_coverart(demuxer);
 2629|    545|    process_tags(demuxer);
 2630|       |
 2631|    545|    probe_first_timestamp(demuxer);
 2632|    545|    if (mkv_d->opts->probe_duration)
  ------------------
  |  Branch (2632:9): [True: 0, False: 545]
  ------------------
 2633|      0|        probe_last_timestamp(demuxer, start_pos);
 2634|    545|    probe_x264_garbage(demuxer);
 2635|    545|    probe_if_image(demuxer);
 2636|       |
 2637|    545|    return 0;
 2638|    545|}
demux_mkv.c:read_ebml_header:
 2423|  39.1k|{
 2424|  39.1k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2425|  39.1k|    stream_t *s = demuxer->stream;
 2426|       |
 2427|  39.1k|    if (ebml_read_id(s) != EBML_ID_EBML)
  ------------------
  |  |    3|  39.1k|#define EBML_ID_EBML                             0x1a45dfa3
  ------------------
  |  Branch (2427:9): [True: 37.2k, False: 1.90k]
  ------------------
 2428|  37.2k|        return 0;
 2429|  1.90k|    struct ebml_ebml ebml_master = {0};
 2430|  1.90k|    struct ebml_parse_ctx parse_ctx = { demuxer->log, .no_error_messages = true };
 2431|  1.90k|    if (ebml_read_element(s, &parse_ctx, &ebml_master, &ebml_ebml_desc) < 0)
  ------------------
  |  Branch (2431:9): [True: 38, False: 1.87k]
  ------------------
 2432|     38|        return 0;
 2433|  1.90k|    bool is_matroska = false, is_webm = false;
 2434|  1.87k|    if (!ebml_master.doc_type) {
  ------------------
  |  Branch (2434:9): [True: 445, False: 1.42k]
  ------------------
 2435|    445|        MP_VERBOSE(demuxer, "File has EBML header but no doctype. "
  ------------------
  |  |   92|    445|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    445|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2436|    445|                   "Assuming \"matroska\".\n");
 2437|    445|        is_matroska = true;
 2438|  1.42k|    } else if (strcmp(ebml_master.doc_type, "matroska") == 0) {
  ------------------
  |  Branch (2438:16): [True: 871, False: 554]
  ------------------
 2439|    871|        is_matroska = true;
 2440|    871|    } else if (strcmp(ebml_master.doc_type, "webm") == 0) {
  ------------------
  |  Branch (2440:16): [True: 0, False: 554]
  ------------------
 2441|      0|        is_webm = true;
 2442|      0|    }
 2443|  1.87k|    if (!is_matroska && !is_webm) {
  ------------------
  |  Branch (2443:9): [True: 554, False: 1.31k]
  |  Branch (2443:25): [True: 554, False: 0]
  ------------------
 2444|    554|        MP_TRACE(demuxer, "no head found\n");
  ------------------
  |  |   94|    554|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    554|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2445|    554|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    554|#define talloc_free                     ta_free
  ------------------
 2446|    554|        return 0;
 2447|    554|    }
 2448|  1.31k|    mkv_d->probably_webm_dash_init &= is_webm;
 2449|  1.31k|    if (ebml_master.doc_type_read_version > 2) {
  ------------------
  |  Branch (2449:9): [True: 9, False: 1.30k]
  ------------------
 2450|      9|        MP_WARN(demuxer, "This looks like a Matroska file, "
  ------------------
  |  |   90|      9|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      9|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2451|      9|                "but we don't support format version %"PRIu64"\n",
 2452|      9|                ebml_master.doc_type_read_version);
 2453|      9|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|      9|#define talloc_free                     ta_free
  ------------------
 2454|      9|        return 0;
 2455|      9|    }
 2456|  1.30k|    if ((ebml_master.n_ebml_read_version
  ------------------
  |  Branch (2456:10): [True: 1.02k, False: 287]
  ------------------
 2457|  1.02k|         && ebml_master.ebml_read_version != EBML_VERSION)
  ------------------
  |  |   31|  1.02k|#define EBML_VERSION 1
  ------------------
  |  Branch (2457:13): [True: 3, False: 1.01k]
  ------------------
 2458|  1.30k|        || (ebml_master.n_ebml_max_size_length
  ------------------
  |  Branch (2458:13): [True: 919, False: 385]
  ------------------
 2459|    919|            && ebml_master.ebml_max_size_length > 8)
  ------------------
  |  Branch (2459:16): [True: 11, False: 908]
  ------------------
 2460|  1.29k|        || (ebml_master.n_ebml_max_id_length
  ------------------
  |  Branch (2460:13): [True: 961, False: 332]
  ------------------
 2461|    961|            && ebml_master.ebml_max_id_length != 4))
  ------------------
  |  Branch (2461:16): [True: 34, False: 927]
  ------------------
 2462|     48|    {
 2463|     48|        MP_WARN(demuxer, "This looks like a Matroska file, "
  ------------------
  |  |   90|     48|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     48|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2464|     48|                "but the header has bad parameters\n");
 2465|     48|        talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|     48|#define talloc_free                     ta_free
  ------------------
 2466|     48|        return 0;
 2467|     48|    }
 2468|  1.25k|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|  1.25k|#define talloc_free                     ta_free
  ------------------
 2469|       |
 2470|  1.25k|    return 1;
 2471|  1.30k|}
demux_mkv.c:read_mkv_segment_header:
 2474|  1.25k|{
 2475|  1.25k|    stream_t *s = demuxer->stream;
 2476|  1.25k|    int num_skip = 0;
 2477|  1.25k|    if (demuxer->params)
  ------------------
  |  Branch (2477:9): [True: 1.25k, False: 0]
  ------------------
 2478|  1.25k|        num_skip = demuxer->params->matroska_wanted_segment;
 2479|       |
 2480|  1.25k|    while (stream_read_peek(s, &(char){0}, 1)) {
  ------------------
  |  Branch (2480:12): [True: 958, False: 301]
  ------------------
 2481|    958|        if (ebml_read_id(s) != MATROSKA_ID_SEGMENT) {
  ------------------
  |  |   13|    958|#define MATROSKA_ID_SEGMENT                      0x18538067
  ------------------
  |  Branch (2481:13): [True: 276, False: 682]
  ------------------
 2482|    276|            MP_VERBOSE(demuxer, "segment not found\n");
  ------------------
  |  |   92|    276|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    276|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2483|    276|            return 0;
 2484|    276|        }
 2485|    682|        MP_DBG(demuxer, "+ a segment...\n");
  ------------------
  |  |   93|    682|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    682|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2486|    682|        uint64_t len = ebml_read_length(s);
 2487|    682|        *segment_end = (len == EBML_UINT_INVALID) ? 0 : stream_tell(s) + len;
  ------------------
  |  |   85|    682|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (2487:24): [True: 3, False: 679]
  ------------------
 2488|    682|        if (num_skip <= 0)
  ------------------
  |  Branch (2488:13): [True: 682, False: 0]
  ------------------
 2489|    682|            return 1;
 2490|      0|        num_skip--;
 2491|      0|        MP_DBG(demuxer, "  (skipping)\n");
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2492|      0|        if (*segment_end <= 0)
  ------------------
  |  Branch (2492:13): [True: 0, False: 0]
  ------------------
 2493|      0|            break;
 2494|      0|        if (*segment_end >= stream_get_size(s))
  ------------------
  |  Branch (2494:13): [True: 0, False: 0]
  ------------------
 2495|      0|            return 0;
 2496|      0|        if (!stream_seek(s, *segment_end)) {
  ------------------
  |  Branch (2496:13): [True: 0, False: 0]
  ------------------
 2497|      0|            MP_WARN(demuxer, "Failed to seek in file\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2498|      0|            return 0;
 2499|      0|        }
 2500|       |        // Segments are like concatenated Matroska files
 2501|      0|        if (!read_ebml_header(demuxer))
  ------------------
  |  Branch (2501:13): [True: 0, False: 0]
  ------------------
 2502|      0|            return 0;
 2503|      0|    }
 2504|       |
 2505|    301|    MP_VERBOSE(demuxer, "End of file, no further segments.\n");
  ------------------
  |  |   92|    301|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    301|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2506|    301|    return 0;
 2507|  1.25k|}
demux_mkv.c:read_header_element:
 1479|  10.8k|{
 1480|  10.8k|    if (id == EBML_ID_INVALID)
  ------------------
  |  |   75|  10.8k|#define EBML_ID_INVALID 0xffffffff
  ------------------
  |  Branch (1480:9): [True: 5.36k, False: 5.47k]
  ------------------
 1481|  5.36k|        return 0;
 1482|       |
 1483|  5.47k|    if (test_header_element(demuxer, id, start_filepos))
  ------------------
  |  Branch (1483:9): [True: 77, False: 5.40k]
  ------------------
 1484|     77|        goto skip;
 1485|       |
 1486|  5.40k|    switch(id) {
  ------------------
  |  Branch (1486:12): [True: 1.50k, False: 3.89k]
  ------------------
 1487|    462|    case MATROSKA_ID_INFO:
  ------------------
  |  |   18|    462|#define MATROSKA_ID_INFO                         0x1549a966
  ------------------
  |  Branch (1487:5): [True: 462, False: 4.93k]
  ------------------
 1488|    462|        return demux_mkv_read_info(demuxer);
 1489|    395|    case MATROSKA_ID_TRACKS:
  ------------------
  |  |   40|    395|#define MATROSKA_ID_TRACKS                       0x1654ae6b
  ------------------
  |  Branch (1489:5): [True: 395, False: 5.00k]
  ------------------
 1490|    395|        return demux_mkv_read_tracks(demuxer);
 1491|      5|    case MATROSKA_ID_CUES:
  ------------------
  |  |  130|      5|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (1491:5): [True: 5, False: 5.39k]
  ------------------
 1492|      5|        return demux_mkv_read_cues(demuxer);
 1493|      0|    case MATROSKA_ID_TAGS:
  ------------------
  |  |  164|      0|#define MATROSKA_ID_TAGS                         0x1254c367
  ------------------
  |  Branch (1493:5): [True: 0, False: 5.40k]
  ------------------
 1494|      0|        return demux_mkv_read_tags(demuxer);
 1495|    641|    case MATROSKA_ID_SEEKHEAD:
  ------------------
  |  |   14|    641|#define MATROSKA_ID_SEEKHEAD                     0x114d9b74
  ------------------
  |  Branch (1495:5): [True: 641, False: 4.75k]
  ------------------
 1496|    641|        return demux_mkv_read_seekhead(demuxer);
 1497|      0|    case MATROSKA_ID_CHAPTERS:
  ------------------
  |  |  145|      0|#define MATROSKA_ID_CHAPTERS                     0x1043a770
  ------------------
  |  Branch (1497:5): [True: 0, False: 5.40k]
  ------------------
 1498|      0|        return demux_mkv_read_chapters(demuxer);
 1499|      0|    case MATROSKA_ID_ATTACHMENTS:
  ------------------
  |  |  138|      0|#define MATROSKA_ID_ATTACHMENTS                  0x1941a469
  ------------------
  |  Branch (1499:5): [True: 0, False: 5.40k]
  ------------------
 1500|      0|        return demux_mkv_read_attachments(demuxer);
 1501|  5.40k|    }
 1502|  3.97k|skip:
 1503|  3.97k|    ebml_read_skip(demuxer->log, -1, demuxer->stream);
 1504|  3.97k|    return 0;
 1505|  5.40k|}
demux_mkv.c:test_header_element:
 1438|  5.47k|{
 1439|  5.47k|    struct header_elem *elem = get_header_element(demuxer, id, element_filepos);
 1440|  5.47k|    if (!elem)
  ------------------
  |  Branch (1440:9): [True: 3.89k, False: 1.58k]
  ------------------
 1441|  3.89k|        return false;
 1442|  1.58k|    if (elem->parsed)
  ------------------
  |  Branch (1442:9): [True: 77, False: 1.50k]
  ------------------
 1443|     77|        return true;
 1444|  1.50k|    elem->parsed = true;
 1445|       |    return false;
 1446|  1.58k|}
demux_mkv.c:get_header_element:
 1411|  6.30k|{
 1412|  6.30k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 1413|       |
 1414|       |    // Note that some files in fact contain a SEEKHEAD with a list of all
 1415|       |    // clusters - we have no use for that.
 1416|  6.30k|    if (!ebml_is_mkv_level1_id(id) || id == MATROSKA_ID_CLUSTER)
  ------------------
  |  |   28|  2.40k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (1416:9): [True: 3.90k, False: 2.40k]
  |  Branch (1416:39): [True: 0, False: 2.40k]
  ------------------
 1417|  3.90k|        return NULL;
 1418|       |
 1419|  5.03k|    for (int n = 0; n < mkv_d->num_headers; n++) {
  ------------------
  |  Branch (1419:21): [True: 3.36k, False: 1.66k]
  ------------------
 1420|  3.36k|        struct header_elem *elem = &mkv_d->headers[n];
 1421|       |        // SEEKHEAD is the only element that can happen multiple times.
 1422|       |        // Other elements might be duplicated (or attempted to be read twice,
 1423|       |        // even if it's only once in the file), but only the first is used.
 1424|  3.36k|        if (elem->id == id && (id != MATROSKA_ID_SEEKHEAD ||
  ------------------
  |  |   14|  1.54k|#define MATROSKA_ID_SEEKHEAD                     0x114d9b74
  ------------------
  |  Branch (1424:13): [True: 770, False: 2.59k]
  |  Branch (1424:32): [True: 733, False: 37]
  ------------------
 1425|     37|                               elem->pos == element_filepos))
  ------------------
  |  Branch (1425:32): [True: 0, False: 37]
  ------------------
 1426|    733|            return elem;
 1427|  3.36k|    }
 1428|  1.66k|    struct header_elem elem = { .id = id, .pos = element_filepos };
 1429|  1.66k|    MP_TARRAY_APPEND(mkv_d, mkv_d->headers, mkv_d->num_headers, elem);
  ------------------
  |  |  105|  1.66k|    do {                                            \
  |  |  106|  1.66k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  1.66k|    do {                                            \
  |  |  |  |   97|  1.66k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  1.66k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  1.66k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  1.66k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.09k, False: 572]
  |  |  |  |  ------------------
  |  |  |  |   99|  1.66k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.09k|    do {                                                        \
  |  |  |  |  |  |   89|  1.09k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.09k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.09k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.09k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.09k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.09k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.09k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.09k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  1.66k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 1.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  1.66k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  1.66k|        (idxvar)++;                                 \
  |  |  109|  1.66k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.66k]
  |  |  ------------------
  ------------------
 1430|  1.66k|    return &mkv_d->headers[mkv_d->num_headers - 1];
 1431|  2.40k|}
demux_mkv.c:demux_mkv_read_info:
  448|    462|{
  449|    462|    mkv_demuxer_t *mkv_d = demuxer->priv;
  450|    462|    stream_t *s = demuxer->stream;
  451|    462|    int res = 0;
  452|       |
  453|    462|    MP_DBG(demuxer, "|+ segment information...\n");
  ------------------
  |  |   93|    462|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    462|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  454|       |
  455|    462|    mkv_d->tc_scale = 1000000;
  456|    462|    mkv_d->duration = 0;
  457|       |
  458|    462|    struct ebml_info info = {0};
  459|    462|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
  460|    462|    if (ebml_read_element(s, &parse_ctx, &info, &ebml_info_desc) < 0)
  ------------------
  |  Branch (460:9): [True: 31, False: 431]
  ------------------
  461|     31|        return -1;
  462|    431|    if (info.muxing_app)
  ------------------
  |  Branch (462:9): [True: 395, False: 36]
  ------------------
  463|    431|        MP_DBG(demuxer, "| + muxing app: %s\n", info.muxing_app);
  ------------------
  |  |   93|    395|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    395|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  464|    431|    if (info.writing_app)
  ------------------
  |  Branch (464:9): [True: 331, False: 100]
  ------------------
  465|    431|        MP_DBG(demuxer, "| + writing app: %s\n", info.writing_app);
  ------------------
  |  |   93|    331|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    331|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  466|    431|    if (info.n_timecode_scale) {
  ------------------
  |  Branch (466:9): [True: 262, False: 169]
  ------------------
  467|    262|        mkv_d->tc_scale = info.timecode_scale;
  468|    262|        MP_DBG(demuxer, "| + timecode scale: %"PRId64"\n", mkv_d->tc_scale);
  ------------------
  |  |   93|    262|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    262|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  469|    262|        if (mkv_d->tc_scale < 1 || mkv_d->tc_scale > INT_MAX) {
  ------------------
  |  Branch (469:13): [True: 5, False: 257]
  |  Branch (469:36): [True: 2, False: 255]
  ------------------
  470|      7|            res = -1;
  471|      7|            goto out;
  472|      7|        }
  473|    262|    }
  474|    424|    if (info.n_duration) {
  ------------------
  |  Branch (474:9): [True: 250, False: 174]
  ------------------
  475|    250|        mkv_d->duration = info.duration * mkv_d->tc_scale / 1e9;
  476|    250|        MP_DBG(demuxer, "| + duration: %.3fs\n",
  ------------------
  |  |   93|    250|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    250|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  477|    250|               mkv_d->duration);
  478|    250|        demuxer->duration = mkv_d->duration;
  479|    250|    }
  480|    424|    if (info.title) {
  ------------------
  |  Branch (480:9): [True: 0, False: 424]
  ------------------
  481|      0|        mp_tags_set_str(demuxer->metadata, "TITLE", info.title);
  482|      0|    }
  483|    424|    if (info.n_segment_uid) {
  ------------------
  |  Branch (483:9): [True: 311, False: 113]
  ------------------
  484|    311|        size_t len = info.segment_uid.len;
  485|    311|        memcpy(demuxer->matroska_data.uid.segment, info.segment_uid.start, len);
  486|    311|        MP_DBG(demuxer, "| + segment uid");
  ------------------
  |  |   93|    311|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    311|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  487|  5.28k|        for (size_t i = 0; i < len; i++)
  ------------------
  |  Branch (487:28): [True: 4.97k, False: 311]
  ------------------
  488|  4.97k|            MP_DBG(demuxer, " %02x", demuxer->matroska_data.uid.segment[i]);
  ------------------
  |  |   93|  4.97k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.97k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  489|    311|        MP_DBG(demuxer, "\n");
  ------------------
  |  |   93|    311|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    311|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|    311|    }
  491|    424|    if (demuxer->params && demuxer->params->matroska_wanted_uids) {
  ------------------
  |  Branch (491:9): [True: 424, False: 0]
  |  Branch (491:28): [True: 0, False: 424]
  ------------------
  492|      0|        if (info.n_segment_uid) {
  ------------------
  |  Branch (492:13): [True: 0, False: 0]
  ------------------
  493|      0|            for (int i = 0; i < demuxer->params->matroska_num_wanted_uids; i++) {
  ------------------
  |  Branch (493:29): [True: 0, False: 0]
  ------------------
  494|      0|                struct matroska_segment_uid *uid = demuxer->params->matroska_wanted_uids + i;
  495|      0|                if (!memcmp(info.segment_uid.start, uid->segment, 16)) {
  ------------------
  |  Branch (495:21): [True: 0, False: 0]
  ------------------
  496|      0|                    demuxer->matroska_data.uid.edition = uid->edition;
  497|      0|                    goto out;
  498|      0|                }
  499|      0|            }
  500|      0|        }
  501|      0|        MP_VERBOSE(demuxer, "This is not one of the wanted files. "
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  502|      0|                "Stopping attempt to open.\n");
  503|      0|        res = -2;
  504|      0|    }
  505|    431| out:
  506|    431|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    431|#define talloc_free                     ta_free
  ------------------
  507|    431|    return res;
  508|    424|}
demux_mkv.c:demux_mkv_read_tracks:
 1029|    395|{
 1030|    395|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1031|    395|    stream_t *s = demuxer->stream;
 1032|       |
 1033|    395|    MP_DBG(demuxer, "|+ segment tracks...\n");
  ------------------
  |  |   93|    395|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    395|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1034|       |
 1035|    395|    struct ebml_tracks tracks = {0};
 1036|    395|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1037|    395|    if (ebml_read_element(s, &parse_ctx, &tracks, &ebml_tracks_desc) < 0)
  ------------------
  |  Branch (1037:9): [True: 43, False: 352]
  ------------------
 1038|     43|        return -1;
 1039|       |
 1040|    352|    mkv_d->tracks = talloc_zero_array(mkv_d, struct mkv_track*,
  ------------------
  |  |   30|    352|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|    352|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    352|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1041|    352|                                      tracks.n_track_entry);
 1042|    931|    for (int i = 0; i < tracks.n_track_entry; i++) {
  ------------------
  |  Branch (1042:21): [True: 579, False: 352]
  ------------------
 1043|    579|        MP_DBG(demuxer, "| + a track...\n");
  ------------------
  |  |   93|    579|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    579|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1044|    579|        parse_trackentry(demuxer, &tracks.track_entry[i]);
 1045|    579|    }
 1046|    352|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    352|#define talloc_free                     ta_free
  ------------------
 1047|    352|    return 0;
 1048|    395|}
demux_mkv.c:parse_trackentry:
  897|    579|{
  898|    579|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
  899|    579|    struct mkv_track *track = talloc_zero(NULL, struct mkv_track);
  ------------------
  |  |   27|    579|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    579|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    579|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  900|    579|    track->last_index_entry = (size_t)-1;
  901|    579|    track->parser_tmp = talloc_new(track);
  ------------------
  |  |   40|    579|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|    579|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  902|       |
  903|    579|    track->tnum = entry->track_number;
  904|    579|    if (track->tnum) {
  ------------------
  |  Branch (904:9): [True: 565, False: 14]
  ------------------
  905|    565|        MP_DBG(demuxer, "|  + Track number: %d\n", track->tnum);
  ------------------
  |  |   93|    565|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    565|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  906|    565|    } else {
  907|     14|        MP_ERR(demuxer, "Missing track number!\n");
  ------------------
  |  |   89|     14|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     14|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  908|     14|    }
  909|    579|    track->uid = entry->track_uid;
  910|       |
  911|    579|    if (entry->name) {
  ------------------
  |  Branch (911:9): [True: 1, False: 578]
  ------------------
  912|      1|        track->name = talloc_strdup(track, entry->name);
  ------------------
  |  |   50|      1|#define talloc_strdup                   ta_xstrdup
  ------------------
  913|      1|        MP_DBG(demuxer, "|  + Name: %s\n", track->name);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  914|      1|    }
  915|       |
  916|    579|    track->type = entry->track_type;
  917|    579|    MP_DBG(demuxer, "|  + Track type: ");
  ------------------
  |  |   93|    579|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    579|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  918|    579|    switch (track->type) {
  919|    292|    case MATROSKA_TRACK_AUDIO:
  ------------------
  |  |   79|    292|#define MATROSKA_TRACK_AUDIO    0x02 /* anything you can hear */
  ------------------
  |  Branch (919:5): [True: 292, False: 287]
  ------------------
  920|    292|        MP_DBG(demuxer, "Audio\n");
  ------------------
  |  |   93|    292|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    292|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  921|    292|        break;
  922|    259|    case MATROSKA_TRACK_VIDEO:
  ------------------
  |  |   78|    259|#define MATROSKA_TRACK_VIDEO    0x01 /* rectangle-shaped pictures aka video */
  ------------------
  |  Branch (922:5): [True: 259, False: 320]
  ------------------
  923|    259|        MP_DBG(demuxer, "Video\n");
  ------------------
  |  |   93|    259|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    259|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  924|    259|        break;
  925|      0|    case MATROSKA_TRACK_SUBTITLE:
  ------------------
  |  |   82|      0|#define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
  ------------------
  |  Branch (925:5): [True: 0, False: 579]
  ------------------
  926|      0|        MP_DBG(demuxer, "Subtitle\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__)
  |  |  ------------------
  ------------------
  927|      0|        break;
  928|     28|    default:
  ------------------
  |  Branch (928:5): [True: 28, False: 551]
  ------------------
  929|     28|        MP_DBG(demuxer, "unknown\n");
  ------------------
  |  |   93|     28|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     28|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  930|     28|        break;
  931|    579|    }
  932|       |
  933|    579|    if (entry->n_audio) {
  ------------------
  |  Branch (933:9): [True: 6, False: 573]
  ------------------
  934|      6|        MP_DBG(demuxer, "|  + Audio track\n");
  ------------------
  |  |   93|      6|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      6|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  935|      6|        parse_trackaudio(demuxer, track, &entry->audio);
  936|      6|    }
  937|       |
  938|    579|    if (entry->n_video) {
  ------------------
  |  Branch (938:9): [True: 185, False: 394]
  ------------------
  939|    185|        MP_DBG(demuxer, "|  + Video track\n");
  ------------------
  |  |   93|    185|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    185|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  940|    185|        parse_trackvideo(demuxer, track, &entry->video);
  941|    185|    }
  942|       |
  943|    579|    if (entry->codec_id) {
  ------------------
  |  Branch (943:9): [True: 543, False: 36]
  ------------------
  944|    543|        track->codec_id = talloc_strdup(track, entry->codec_id);
  ------------------
  |  |   50|    543|#define talloc_strdup                   ta_xstrdup
  ------------------
  945|    543|        MP_DBG(demuxer, "|  + Codec ID: %s\n", track->codec_id);
  ------------------
  |  |   93|    543|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    543|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  946|    543|    } else {
  947|     36|        MP_ERR(demuxer, "Missing codec ID!\n");
  ------------------
  |  |   89|     36|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     36|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  948|     36|        track->codec_id = "";
  949|     36|    }
  950|       |
  951|    579|    if (entry->n_codec_private && entry->codec_private.len <= 0x10000000) {
  ------------------
  |  Branch (951:9): [True: 484, False: 95]
  |  Branch (951:35): [True: 484, False: 0]
  ------------------
  952|    484|        int len = entry->codec_private.len;
  953|    484|        track->private_data = talloc_size(track, len + AV_LZO_INPUT_PADDING);
  ------------------
  |  |   43|    484|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|    484|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|    484|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    484|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    484|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    484|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|    484|        memcpy(track->private_data, entry->codec_private.start, len);
  955|    484|        memset(track->private_data + len, 0, AV_LZO_INPUT_PADDING);
  956|    484|        track->private_size = len;
  957|    484|        MP_DBG(demuxer, "|  + CodecPrivate, length %u\n", track->private_size);
  ------------------
  |  |   93|    484|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    484|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  958|    484|    }
  959|       |
  960|    579|    if (entry->language_bcp47) {
  ------------------
  |  Branch (960:9): [True: 0, False: 579]
  ------------------
  961|      0|        track->language = talloc_strdup(track, entry->language_bcp47);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  962|      0|        MP_DBG(demuxer, "|  + LanguageBCP47: %s\n", track->language);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  963|    579|    } else if (entry->language) {
  ------------------
  |  Branch (963:16): [True: 1, False: 578]
  ------------------
  964|      1|        track->language = talloc_strdup(track, entry->language);
  ------------------
  |  |   50|      1|#define talloc_strdup                   ta_xstrdup
  ------------------
  965|      1|        MP_DBG(demuxer, "|  + Language: %s\n", track->language);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  966|    578|    } else {
  967|    578|        track->language = talloc_strdup(track, "eng");
  ------------------
  |  |   50|    578|#define talloc_strdup                   ta_xstrdup
  ------------------
  968|    578|    }
  969|       |
  970|    579|    if (entry->n_flag_default) {
  ------------------
  |  Branch (970:9): [True: 545, False: 34]
  ------------------
  971|    545|        track->default_track = entry->flag_default;
  972|    545|        MP_DBG(demuxer, "|  + Default flag: %d\n", track->default_track);
  ------------------
  |  |   93|    545|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    545|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  973|    545|    } else {
  974|     34|        track->default_track = 1;
  975|     34|    }
  976|       |
  977|    579|    if (entry->n_flag_forced) {
  ------------------
  |  Branch (977:9): [True: 0, False: 579]
  ------------------
  978|      0|        track->forced_track = entry->flag_forced;
  979|      0|        MP_DBG(demuxer, "|  + Forced flag: %d\n", track->forced_track);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  980|      0|    }
  981|       |
  982|    579|    if (entry->n_flag_visual_impaired) {
  ------------------
  |  Branch (982:9): [True: 0, False: 579]
  ------------------
  983|      0|        track->visual_impaired_track = entry->flag_visual_impaired;
  984|      0|        MP_DBG(demuxer, "|  + Visual-Impaired flag: %d\n", track->visual_impaired_track);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  985|      0|    }
  986|       |
  987|    579|    if (entry->n_flag_hearing_impaired) {
  ------------------
  |  Branch (987:9): [True: 0, False: 579]
  ------------------
  988|      0|        track->hearing_impaired_track = entry->flag_hearing_impaired;
  989|      0|        MP_DBG(demuxer, "|  + Hearing-Impaired flag: %d\n", track->hearing_impaired_track);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  990|      0|    }
  991|       |
  992|    579|    if (entry->n_flag_original) {
  ------------------
  |  Branch (992:9): [True: 0, False: 579]
  ------------------
  993|      0|        track->original_track = entry->flag_original;
  994|      0|        MP_DBG(demuxer, "|  + Original flag: %d\n", track->original_track);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  995|      0|    }
  996|       |
  997|    579|    if (entry->n_flag_commentary) {
  ------------------
  |  Branch (997:9): [True: 0, False: 579]
  ------------------
  998|      0|        track->commentary_track = entry->flag_commentary;
  999|      0|        MP_DBG(demuxer, "|  + Commentary flag: %d\n", track->commentary_track);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1000|      0|    }
 1001|       |
 1002|    579|    if (entry->n_default_duration) {
  ------------------
  |  Branch (1002:9): [True: 0, False: 579]
  ------------------
 1003|      0|        track->default_duration = entry->default_duration / 1e9;
 1004|      0|        if (entry->default_duration == 0) {
  ------------------
  |  Branch (1004:13): [True: 0, False: 0]
  ------------------
 1005|      0|            MP_DBG(demuxer, "|  + Default duration: 0");
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1006|      0|        } else {
 1007|      0|            track->v_frate = 1e9 / entry->default_duration;
 1008|      0|            MP_DBG(demuxer, "|  + Default duration: %.3fms ( = %.3f fps)\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__)
  |  |  ------------------
  ------------------
 1009|      0|                   entry->default_duration / 1000000.0, track->v_frate);
 1010|      0|        }
 1011|      0|    }
 1012|       |
 1013|    579|    if (entry->n_content_encodings)
  ------------------
  |  Branch (1013:9): [True: 0, False: 579]
  ------------------
 1014|      0|        parse_trackencodings(demuxer, track, &entry->content_encodings);
 1015|       |
 1016|    579|    if (entry->n_codec_delay)
  ------------------
  |  Branch (1016:9): [True: 0, False: 579]
  ------------------
 1017|      0|        track->codec_delay = entry->codec_delay / 1e9;
 1018|       |
 1019|    579|    if (entry->n_block_addition_mapping) {
  ------------------
  |  Branch (1019:9): [True: 0, False: 579]
  ------------------
 1020|      0|        parse_block_addition_mapping(demuxer, track,
 1021|      0|                                     entry->block_addition_mapping,
 1022|      0|                                     entry->n_block_addition_mapping);
 1023|      0|    }
 1024|       |
 1025|    579|    mkv_d->tracks[mkv_d->num_tracks++] = track;
 1026|    579|}
demux_mkv.c:parse_trackaudio:
  584|      6|{
  585|      6|    if (audio->n_sampling_frequency && valid_samplerate(audio->sampling_frequency)) {
  ------------------
  |  Branch (585:9): [True: 5, False: 1]
  |  Branch (585:40): [True: 5, False: 0]
  ------------------
  586|      5|        track->a_sfreq = audio->sampling_frequency;
  587|      5|        MP_DBG(demuxer, "|   + Sampling frequency: %f\n", track->a_sfreq);
  ------------------
  |  |   93|      5|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  588|      5|    } else {
  589|      1|        track->a_sfreq = 8000;
  590|      1|    }
  591|      6|    if (audio->n_output_sampling_frequency && valid_samplerate(audio->output_sampling_frequency)) {
  ------------------
  |  Branch (591:9): [True: 0, False: 6]
  |  Branch (591:47): [True: 0, False: 0]
  ------------------
  592|      0|        track->a_osfreq = audio->output_sampling_frequency;
  593|      0|        MP_DBG(demuxer, "|   + Output sampling frequency: %f\n", track->a_osfreq);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  594|      6|    } else {
  595|      6|        track->a_osfreq = track->a_sfreq;
  596|      6|    }
  597|      6|    if (audio->n_bit_depth) {
  ------------------
  |  Branch (597:9): [True: 0, False: 6]
  ------------------
  598|      0|        track->a_bps = audio->bit_depth;
  599|      0|        MP_DBG(demuxer, "|   + Bit depth: %"PRIu32"\n", track->a_bps);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  600|      0|    }
  601|      6|    if (audio->n_channels) {
  ------------------
  |  Branch (601:9): [True: 5, False: 1]
  ------------------
  602|      5|        track->a_channels = audio->channels;
  603|      5|        MP_DBG(demuxer, "|   + Channels: %"PRIu32"\n", track->a_channels);
  ------------------
  |  |   93|      5|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  604|      5|    } else {
  605|      1|        track->a_channels = 1;
  606|      1|    }
  607|      6|}
demux_mkv.c:valid_samplerate:
  578|      5|{
  579|      5|    return rate > 0 && rate <= INT_MAX;
  ------------------
  |  Branch (579:12): [True: 5, False: 0]
  |  Branch (579:24): [True: 5, False: 0]
  ------------------
  580|      5|}
demux_mkv.c:parse_trackvideo:
  742|    185|{
  743|    185|    if (video->n_frame_rate) {
  ------------------
  |  Branch (743:9): [True: 0, False: 185]
  ------------------
  744|      0|        MP_DBG(demuxer, "|   + Frame rate: %f (ignored)\n", video->frame_rate);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  745|      0|    }
  746|    185|    if (video->n_display_width) {
  ------------------
  |  Branch (746:9): [True: 167, False: 18]
  ------------------
  747|    167|        track->v_dwidth = video->display_width;
  748|    167|        track->v_dwidth_set = true;
  749|    167|        MP_DBG(demuxer, "|   + Display width: %"PRIu32"\n", track->v_dwidth);
  ------------------
  |  |   93|    167|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    167|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  750|    167|    }
  751|    185|    if (video->n_display_height) {
  ------------------
  |  Branch (751:9): [True: 165, False: 20]
  ------------------
  752|    165|        track->v_dheight = video->display_height;
  753|    165|        track->v_dheight_set = true;
  754|    165|        MP_DBG(demuxer, "|   + Display height: %"PRIu32"\n", track->v_dheight);
  ------------------
  |  |   93|    165|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    165|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  755|    165|    }
  756|    185|    if (video->n_pixel_width) {
  ------------------
  |  Branch (756:9): [True: 174, False: 11]
  ------------------
  757|    174|        track->v_width = video->pixel_width;
  758|    174|        MP_DBG(demuxer, "|   + Pixel width: %"PRIu32"\n", track->v_width);
  ------------------
  |  |   93|    174|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    174|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  759|    174|    }
  760|    185|    if (video->n_pixel_height) {
  ------------------
  |  Branch (760:9): [True: 171, False: 14]
  ------------------
  761|    171|        track->v_height = video->pixel_height;
  762|    171|        MP_DBG(demuxer, "|   + Pixel height: %"PRIu32"\n", track->v_height);
  ------------------
  |  |   93|    171|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    171|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  763|    171|    }
  764|    185|    if (video->n_colour_space) {
  ------------------
  |  Branch (764:9): [True: 0, False: 185]
  ------------------
  765|      0|        uint8_t *d = (uint8_t *)&video->colour_space.start[0];
  766|      0|        track->colorspace = d[0] | ((uint32_t)d[1] << 8) | ((uint32_t)d[2] << 16) | ((uint32_t)d[3] << 24);
  767|      0|        MP_DBG(demuxer, "|   + Colorspace: %#"PRIx32"\n", track->colorspace);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  768|      0|    }
  769|    185|    if (video->n_stereo_mode) {
  ------------------
  |  Branch (769:9): [True: 0, False: 185]
  ------------------
  770|      0|        const char *name = MP_STEREO3D_NAME_DEF(video->stereo_mode, NULL);
  ------------------
  |  |   75|      0|#define MP_STEREO3D_NAME_DEF(x, def) m_opt_choice_str_def(mp_stereo3d_names, x, def)
  ------------------
  771|      0|        if (name) {
  ------------------
  |  Branch (771:13): [True: 0, False: 0]
  ------------------
  772|      0|            track->stereo_mode = video->stereo_mode;
  773|      0|            MP_DBG(demuxer, "|   + StereoMode: %s\n", name);
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  774|      0|        } else {
  775|      0|            MP_WARN(demuxer, "Unknown StereoMode: %"PRIu64"\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__)
  |  |  ------------------
  ------------------
  776|      0|                    video->stereo_mode);
  777|      0|        }
  778|      0|    }
  779|    185|    if (video->n_pixel_crop_top) {
  ------------------
  |  Branch (779:9): [True: 1, False: 184]
  ------------------
  780|      1|        track->v_crop_top = video->pixel_crop_top;
  781|      1|        MP_DBG(demuxer, "|   + Crop top: %"PRIu32"\n", track->v_crop_top);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  782|      1|    }
  783|    185|    if (video->n_pixel_crop_left) {
  ------------------
  |  Branch (783:9): [True: 0, False: 185]
  ------------------
  784|      0|        track->v_crop_left = video->pixel_crop_left;
  785|      0|        MP_DBG(demuxer, "|   + Crop left: %"PRIu32"\n", track->v_crop_left);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  786|      0|    }
  787|    185|    if (video->n_pixel_crop_right) {
  ------------------
  |  Branch (787:9): [True: 0, False: 185]
  ------------------
  788|      0|        track->v_crop_right = video->pixel_crop_right;
  789|      0|        MP_DBG(demuxer, "|   + Crop right: %"PRIu32"\n", track->v_crop_right);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  790|      0|    }
  791|    185|    if (video->n_pixel_crop_bottom) {
  ------------------
  |  Branch (791:9): [True: 1, False: 184]
  ------------------
  792|      1|        track->v_crop_bottom = video->pixel_crop_bottom;
  793|      1|        MP_DBG(demuxer, "|   + Crop bottom: %"PRIu32"\n", track->v_crop_bottom);
  ------------------
  |  |   93|      1|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      1|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  794|      1|    }
  795|    185|    if (video->n_colour)
  ------------------
  |  Branch (795:9): [True: 1, False: 184]
  ------------------
  796|      1|        parse_trackcolour(demuxer, track, &video->colour);
  797|    185|    if (video->n_projection)
  ------------------
  |  Branch (797:9): [True: 0, False: 185]
  ------------------
  798|      0|        parse_trackprojection(demuxer, track, &video->projection);
  799|    185|}
demux_mkv.c:parse_trackcolour:
  626|      1|{
  627|       |    // Note: As per matroska spec, the order is consistent with ISO/IEC
  628|       |    // 23001-8:2013/DCOR1, which is the same order used by libavutil/pixfmt.h,
  629|       |    // so we can just reuse our avcol_ conversion functions.
  630|      1|    if (colour->n_matrix_coefficients) {
  ------------------
  |  Branch (630:9): [True: 0, False: 1]
  ------------------
  631|      0|        track->repr.sys = pl_system_from_av(colour->matrix_coefficients);
  632|      0|        MP_DBG(demuxer, "|    + Matrix: %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__)
  |  |  ------------------
  ------------------
  633|      0|                   m_opt_choice_str(pl_csp_names, track->repr.sys));
  634|      0|    }
  635|      1|    if (colour->n_chroma_siting_horz && colour->n_chroma_siting_vert) {
  ------------------
  |  Branch (635:9): [True: 0, False: 1]
  |  Branch (635:41): [True: 0, False: 0]
  ------------------
  636|      0|        track->chroma_location = chroma_location_from_pos(demuxer,
  637|      0|                                                          colour->chroma_siting_horz,
  638|      0|                                                          colour->chroma_siting_vert);
  639|      0|        MP_DBG(demuxer, "|    + ChromaLocation: %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__)
  |  |  ------------------
  ------------------
  640|      0|                   m_opt_choice_str(pl_chroma_names, track->chroma_location));
  641|      0|    }
  642|      1|    if (colour->n_primaries) {
  ------------------
  |  Branch (642:9): [True: 0, False: 1]
  ------------------
  643|      0|        track->color.primaries = pl_primaries_from_av(colour->primaries);
  644|      0|        MP_DBG(demuxer, "|    + Primaries: %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__)
  |  |  ------------------
  ------------------
  645|      0|                   m_opt_choice_str(pl_csp_prim_names, track->color.primaries));
  646|      0|    }
  647|      1|    if (colour->n_transfer_characteristics) {
  ------------------
  |  Branch (647:9): [True: 0, False: 1]
  ------------------
  648|      0|        track->color.transfer = pl_transfer_from_av(colour->transfer_characteristics);
  649|      0|        MP_DBG(demuxer, "|    + Gamma: %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__)
  |  |  ------------------
  ------------------
  650|      0|                   m_opt_choice_str(pl_csp_trc_names, track->color.transfer));
  651|      0|    }
  652|      1|    if (colour->n_range) {
  ------------------
  |  Branch (652:9): [True: 0, False: 1]
  ------------------
  653|      0|        track->repr.levels = pl_levels_from_av(colour->range);
  654|      0|        MP_DBG(demuxer, "|    + Levels: %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__)
  |  |  ------------------
  ------------------
  655|      0|                   m_opt_choice_str(pl_csp_levels_names, track->repr.levels));
  656|      0|    }
  657|      1|    if (colour->n_max_cll) {
  ------------------
  |  Branch (657:9): [True: 0, False: 1]
  ------------------
  658|      0|        track->color.hdr.max_cll = colour->max_cll;
  659|      0|        MP_DBG(demuxer, "|    + MaxCLL: %"PRIu64"\n", colour->max_cll);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  660|      0|    }
  661|      1|    if (colour->n_max_fall) {
  ------------------
  |  Branch (661:9): [True: 0, False: 1]
  ------------------
  662|      0|        track->color.hdr.max_fall = colour->max_fall;
  663|      0|        MP_DBG(demuxer, "|    + MaxFALL: %"PRIu64"\n", colour->max_cll);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  664|      0|    }
  665|      1|    if (colour->n_mastering_metadata) {
  ------------------
  |  Branch (665:9): [True: 0, False: 1]
  ------------------
  666|      0|        struct ebml_mastering_metadata *mastering = &colour->mastering_metadata;
  667|       |
  668|      0|        if (mastering->n_primary_r_chromaticity_x) {
  ------------------
  |  Branch (668:13): [True: 0, False: 0]
  ------------------
  669|      0|            track->color.hdr.prim.red.x = mastering->primary_r_chromaticity_x;
  670|      0|            MP_DBG(demuxer, "|    + PrimaryRChromaticityX: %f\n", track->color.hdr.prim.red.x);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  671|      0|        }
  672|      0|        if (mastering->n_primary_r_chromaticity_y) {
  ------------------
  |  Branch (672:13): [True: 0, False: 0]
  ------------------
  673|      0|            track->color.hdr.prim.red.y = mastering->primary_r_chromaticity_y;
  674|      0|            MP_DBG(demuxer, "|    + PrimaryRChromaticityY: %f\n", track->color.hdr.prim.red.y);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  675|      0|        }
  676|      0|        if (mastering->n_primary_g_chromaticity_x) {
  ------------------
  |  Branch (676:13): [True: 0, False: 0]
  ------------------
  677|      0|            track->color.hdr.prim.green.x = mastering->primary_g_chromaticity_x;
  678|      0|            MP_DBG(demuxer, "|    + PrimaryGChromaticityX: %f\n", track->color.hdr.prim.green.x);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  679|      0|        }
  680|      0|        if (mastering->n_primary_g_chromaticity_y) {
  ------------------
  |  Branch (680:13): [True: 0, False: 0]
  ------------------
  681|      0|            track->color.hdr.prim.green.y = mastering->primary_g_chromaticity_y;
  682|      0|            MP_DBG(demuxer, "|    + PrimaryGChromaticityY: %f\n", track->color.hdr.prim.green.y);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  683|      0|        }
  684|      0|        if (mastering->n_primary_b_chromaticity_x) {
  ------------------
  |  Branch (684:13): [True: 0, False: 0]
  ------------------
  685|      0|            track->color.hdr.prim.blue.x = mastering->primary_b_chromaticity_x;
  686|      0|            MP_DBG(demuxer, "|    + PrimaryBChromaticityX: %f\n", track->color.hdr.prim.blue.x);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  687|      0|        }
  688|      0|        if (mastering->n_primary_b_chromaticity_y) {
  ------------------
  |  Branch (688:13): [True: 0, False: 0]
  ------------------
  689|      0|            track->color.hdr.prim.blue.y = mastering->primary_b_chromaticity_y;
  690|      0|            MP_DBG(demuxer, "|    + PrimaryBChromaticityY: %f\n", track->color.hdr.prim.blue.y);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  691|      0|        }
  692|      0|        if (mastering->n_white_point_chromaticity_x) {
  ------------------
  |  Branch (692:13): [True: 0, False: 0]
  ------------------
  693|      0|            track->color.hdr.prim.white.x = mastering->white_point_chromaticity_x;
  694|      0|            MP_DBG(demuxer, "|    + WhitePointChromaticityX: %f\n", track->color.hdr.prim.white.x);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  695|      0|        }
  696|      0|        if (mastering->n_white_point_chromaticity_y) {
  ------------------
  |  Branch (696:13): [True: 0, False: 0]
  ------------------
  697|      0|            track->color.hdr.prim.white.y = mastering->white_point_chromaticity_y;
  698|      0|            MP_DBG(demuxer, "|    + WhitePointChromaticityY: %f\n", track->color.hdr.prim.white.y);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  699|      0|        }
  700|      0|        if (mastering->n_luminance_min) {
  ------------------
  |  Branch (700:13): [True: 0, False: 0]
  ------------------
  701|      0|            track->color.hdr.min_luma = mastering->luminance_min;
  702|      0|            MP_DBG(demuxer, "|    + LuminanceMin: %f\n", track->color.hdr.min_luma);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  703|      0|        }
  704|      0|        if (mastering->n_luminance_max) {
  ------------------
  |  Branch (704:13): [True: 0, False: 0]
  ------------------
  705|      0|            track->color.hdr.max_luma = mastering->luminance_max;
  706|      0|            MP_DBG(demuxer, "|    + LuminanceMax: %f\n", track->color.hdr.max_luma);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  707|      0|        }
  708|      0|    }
  709|      1|}
demux_mkv.c:demux_mkv_read_cues:
 1089|      5|{
 1090|      5|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1091|      5|    stream_t *s = demuxer->stream;
 1092|       |
 1093|      5|    if (demuxer->opts->index_mode != 1 || mkv_d->index_complete) {
  ------------------
  |  Branch (1093:9): [True: 0, False: 5]
  |  Branch (1093:43): [True: 0, False: 5]
  ------------------
 1094|      0|        ebml_read_skip(demuxer->log, -1, s);
 1095|      0|        return 0;
 1096|      0|    }
 1097|       |
 1098|      5|    MP_VERBOSE(demuxer, "Parsing cues...\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__)
  |  |  ------------------
  ------------------
 1099|      5|    struct ebml_cues cues = {0};
 1100|      5|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1101|      5|    if (ebml_read_element(s, &parse_ctx, &cues, &ebml_cues_desc) < 0)
  ------------------
  |  Branch (1101:9): [True: 0, False: 5]
  ------------------
 1102|      0|        return -1;
 1103|       |
 1104|      5|    for (int i = 0; i < cues.n_cue_point; i++) {
  ------------------
  |  Branch (1104:21): [True: 0, False: 5]
  ------------------
 1105|      0|        struct ebml_cue_point *cuepoint = &cues.cue_point[i];
 1106|      0|        if (cuepoint->n_cue_time != 1 || !cuepoint->n_cue_track_positions) {
  ------------------
  |  Branch (1106:13): [True: 0, False: 0]
  |  Branch (1106:42): [True: 0, False: 0]
  ------------------
 1107|      0|            MP_WARN(demuxer, "Malformed CuePoint element\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1108|      0|            goto done;
 1109|      0|        }
 1110|      0|        if (cuepoint->cue_time / 1e9 > mkv_d->duration / mkv_d->tc_scale * 10 &&
  ------------------
  |  Branch (1110:13): [True: 0, False: 0]
  ------------------
 1111|      0|            mkv_d->duration != 0)
  ------------------
  |  Branch (1111:13): [True: 0, False: 0]
  ------------------
 1112|      0|            goto done;
 1113|      0|    }
 1114|      5|    if (cues.n_cue_point <= 3) // probably too sparse and will just break seeking
  ------------------
  |  Branch (1114:9): [True: 5, False: 0]
  ------------------
 1115|      5|        goto done;
 1116|       |
 1117|       |    // Discard incremental index.
 1118|      0|    mkv_d->num_indexes = 0;
 1119|      0|    mkv_d->index_has_durations = false;
 1120|       |
 1121|      0|    for (int i = 0; i < cues.n_cue_point; i++) {
  ------------------
  |  Branch (1121:21): [True: 0, False: 0]
  ------------------
 1122|      0|        struct ebml_cue_point *cuepoint = &cues.cue_point[i];
 1123|      0|        uint64_t time = cuepoint->cue_time;
 1124|      0|        for (int c = 0; c < cuepoint->n_cue_track_positions; c++) {
  ------------------
  |  Branch (1124:25): [True: 0, False: 0]
  ------------------
 1125|      0|            struct ebml_cue_track_positions *trackpos =
 1126|      0|                &cuepoint->cue_track_positions[c];
 1127|      0|            uint64_t pos = mkv_d->segment_start + trackpos->cue_cluster_position;
 1128|      0|            cue_index_add(demuxer, trackpos->cue_track, pos,
 1129|      0|                          time, trackpos->cue_duration);
 1130|      0|            mkv_d->index_has_durations |= trackpos->n_cue_duration > 0;
 1131|      0|            MP_TRACE(demuxer, "|+ found cue point for track %"PRIu64": "
  ------------------
  |  |   94|      0|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1132|      0|                     "timecode %"PRIu64", filepos: %"PRIu64" "
 1133|      0|                     "offset %"PRIu64", duration %"PRIu64"\n",
 1134|      0|                     trackpos->cue_track, time, pos,
 1135|      0|                     trackpos->cue_relative_position, trackpos->cue_duration);
 1136|      0|        }
 1137|      0|    }
 1138|       |
 1139|       |    // Do not attempt to create index on the fly.
 1140|      0|    mkv_d->index_complete = true;
 1141|       |
 1142|      5|done:
 1143|      5|    if (!mkv_d->index_complete)
  ------------------
  |  Branch (1143:9): [True: 5, False: 0]
  ------------------
 1144|      5|        MP_WARN(demuxer, "Discarding potentially broken or useless index.\n");
  ------------------
  |  |   90|      5|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1145|      5|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|      5|#define talloc_free                     ta_free
  ------------------
 1146|      5|    return 0;
 1147|      0|}
demux_mkv.c:cue_index_add:
 1052|     12|{
 1053|     12|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1054|       |
 1055|     12|    MP_TARRAY_GROW(mkv_d, mkv_d->indexes, mkv_d->num_indexes);
  ------------------
  |  |   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: 11, False: 1]
  |  |  ------------------
  |  |   99|     12|            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|     12|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 12]
  |  |  ------------------
  ------------------
 1056|       |
 1057|     12|    mkv_d->indexes[mkv_d->num_indexes] = (mkv_index_t) {
 1058|     12|        .tnum = track_id,
 1059|     12|        .filepos = filepos,
 1060|     12|        .timecode = timecode,
 1061|     12|        .duration = duration,
 1062|     12|    };
 1063|       |
 1064|     12|    mkv_d->num_indexes++;
 1065|     12|}
demux_mkv.c:demux_mkv_read_seekhead:
 1449|    641|{
 1450|    641|    struct mkv_demuxer *mkv_d = demuxer->priv;
 1451|    641|    struct stream *s = demuxer->stream;
 1452|    641|    int res = 0;
 1453|    641|    struct ebml_seek_head seekhead = {0};
 1454|    641|    struct ebml_parse_ctx parse_ctx = {demuxer->log};
 1455|       |
 1456|    641|    MP_DBG(demuxer, "Parsing seek head...\n");
  ------------------
  |  |   93|    641|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    641|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1457|    641|    if (ebml_read_element(s, &parse_ctx, &seekhead, &ebml_seek_head_desc) < 0) {
  ------------------
  |  Branch (1457:9): [True: 56, False: 585]
  ------------------
 1458|     56|        res = -1;
 1459|     56|        goto out;
 1460|     56|    }
 1461|  2.00k|    for (int i = 0; i < seekhead.n_seek; i++) {
  ------------------
  |  Branch (1461:21): [True: 1.41k, False: 585]
  ------------------
 1462|  1.41k|        struct ebml_seek *seek = &seekhead.seek[i];
 1463|  1.41k|        if (seek->n_seek_id != 1 || seek->n_seek_position != 1) {
  ------------------
  |  Branch (1463:13): [True: 504, False: 912]
  |  Branch (1463:37): [True: 86, False: 826]
  ------------------
 1464|    590|            MP_WARN(demuxer, "Invalid SeekHead entry\n");
  ------------------
  |  |   90|    590|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    590|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1465|    590|            continue;
 1466|    590|        }
 1467|    826|        uint64_t pos = seek->seek_position + mkv_d->segment_start;
 1468|    826|        MP_TRACE(demuxer, "Element 0x%"PRIx32" at %"PRIu64".\n",
  ------------------
  |  |   94|    826|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    826|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1469|    826|                 seek->seek_id, pos);
 1470|    826|        get_header_element(demuxer, seek->seek_id, pos);
 1471|    826|    }
 1472|    641| out:
 1473|    641|    talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|    641|#define talloc_free                     ta_free
  ------------------
 1474|    641|    return res;
 1475|    585|}
demux_mkv.c:read_deferred_element:
 1509|    137|{
 1510|    137|    stream_t *s = demuxer->stream;
 1511|       |
 1512|    137|    if (elem->parsed)
  ------------------
  |  Branch (1512:9): [True: 0, False: 137]
  ------------------
 1513|      0|        return 0;
 1514|    137|    elem->parsed = true;
 1515|    137|    MP_VERBOSE(demuxer, "Seeking to %"PRIu64" to read header element "
  ------------------
  |  |   92|    137|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    137|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1516|    137|               "0x%"PRIx32".\n",
 1517|    137|               elem->pos, elem->id);
 1518|    137|    if (!stream_seek(s, elem->pos)) {
  ------------------
  |  Branch (1518:9): [True: 0, False: 137]
  ------------------
 1519|      0|        MP_WARN(demuxer, "Failed to seek when reading header element.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1520|      0|        return 0;
 1521|      0|    }
 1522|    137|    if (ebml_read_id(s) != elem->id) {
  ------------------
  |  Branch (1522:9): [True: 124, False: 13]
  ------------------
 1523|    124|        MP_ERR(demuxer, "Expected element 0x%"PRIx32" not found\n",
  ------------------
  |  |   89|    124|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    124|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1524|    124|               elem->id);
 1525|    124|        return 0;
 1526|    124|    }
 1527|     13|    elem->parsed = false; // don't make read_header_element skip it
 1528|     13|    return read_header_element(demuxer, elem->id, elem->pos);
 1529|    137|}
demux_mkv.c:display_create_tracks:
 1592|    545|{
 1593|    545|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1594|       |
 1595|  1.12k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (1595:21): [True: 579, False: 545]
  ------------------
 1596|    579|        switch (mkv_d->tracks[i]->type) {
  ------------------
  |  Branch (1596:17): [True: 551, False: 28]
  ------------------
 1597|    259|        case MATROSKA_TRACK_VIDEO:
  ------------------
  |  |   78|    259|#define MATROSKA_TRACK_VIDEO    0x01 /* rectangle-shaped pictures aka video */
  ------------------
  |  Branch (1597:9): [True: 259, False: 320]
  ------------------
 1598|    259|            demux_mkv_open_video(demuxer, mkv_d->tracks[i], i);
 1599|    259|            break;
 1600|    292|        case MATROSKA_TRACK_AUDIO:
  ------------------
  |  |   79|    292|#define MATROSKA_TRACK_AUDIO    0x02 /* anything you can hear */
  ------------------
  |  Branch (1600:9): [True: 292, False: 287]
  ------------------
 1601|    292|            demux_mkv_open_audio(demuxer, mkv_d->tracks[i], i);
 1602|    292|            break;
 1603|      0|        case MATROSKA_TRACK_SUBTITLE:
  ------------------
  |  |   82|      0|#define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
  ------------------
  |  Branch (1603:9): [True: 0, False: 579]
  ------------------
 1604|      0|            demux_mkv_open_sub(demuxer, mkv_d->tracks[i], i);
 1605|      0|            break;
 1606|    579|        }
 1607|    579|    }
 1608|    545|}
demux_mkv.c:demux_mkv_open_video:
 1641|    259|{
 1642|    259|    unsigned char *extradata = NULL;
 1643|    259|    unsigned int extradata_size = 0;
 1644|    259|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
 1645|    259|    init_track(demuxer, track, sh, idx);
 1646|    259|    struct mp_codec_params *sh_v = sh->codec;
 1647|       |
 1648|    259|    sh_v->bits_per_coded_sample = 24;
 1649|       |
 1650|    259|    if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")) { /* AVI compatibility mode */
  ------------------
  |  Branch (1650:9): [True: 193, False: 66]
  ------------------
 1651|       |        // The private_data contains a BITMAPINFOHEADER struct
 1652|    193|        if (track->private_data == NULL || track->private_size < 40)
  ------------------
  |  Branch (1652:13): [True: 2, False: 191]
  |  Branch (1652:44): [True: 4, False: 187]
  ------------------
 1653|      6|            goto done;
 1654|       |
 1655|    187|        unsigned char *h = track->private_data;
 1656|    187|        if (track->v_width == 0)
  ------------------
  |  Branch (1656:13): [True: 42, False: 145]
  ------------------
 1657|     42|            track->v_width = AV_RL32(h + 4);        // biWidth
 1658|    187|        if (track->v_height == 0)
  ------------------
  |  Branch (1658:13): [True: 43, False: 144]
  ------------------
 1659|     43|            track->v_height = AV_RL32(h + 8);       // biHeight
 1660|    187|        sh_v->bits_per_coded_sample = AV_RL16(h + 14); // biBitCount
 1661|    187|        sh_v->codec_tag = AV_RL32(h + 16);            // biCompression
 1662|       |
 1663|    187|        extradata = track->private_data + 40;
 1664|    187|        extradata_size = track->private_size - 40;
 1665|    187|        mp_set_codec_from_tag(sh_v);
 1666|       |        // The DTS are the PTS if the codec does not reorder frames.
 1667|    187|        const AVCodecDescriptor *desc = avcodec_descriptor_get(mp_codec_to_av_codec_id(sh_v->codec));
 1668|    187|        track->block_dts = !desc || (desc->props & AV_CODEC_PROP_REORDER);
  ------------------
  |  Branch (1668:28): [True: 24, False: 163]
  |  Branch (1668:37): [True: 158, False: 5]
  ------------------
 1669|    187|    } else if (track->private_size >= RVPROPERTIES_SIZE
  ------------------
  |  |  281|    132|#define RVPROPERTIES_SIZE  34
  ------------------
  |  Branch (1669:16): [True: 29, False: 37]
  ------------------
 1670|     29|               && (!strcmp(track->codec_id, "V_REAL/RV10")
  ------------------
  |  Branch (1670:20): [True: 0, False: 29]
  ------------------
 1671|     29|                || !strcmp(track->codec_id, "V_REAL/RV20")
  ------------------
  |  Branch (1671:20): [True: 0, False: 29]
  ------------------
 1672|     29|                || !strcmp(track->codec_id, "V_REAL/RV30")
  ------------------
  |  Branch (1672:20): [True: 0, False: 29]
  ------------------
 1673|     29|                || !strcmp(track->codec_id, "V_REAL/RV40")))
  ------------------
  |  Branch (1673:20): [True: 0, False: 29]
  ------------------
 1674|      0|    {
 1675|      0|        unsigned char *src;
 1676|      0|        unsigned int cnt;
 1677|       |
 1678|      0|        src = (uint8_t *) track->private_data + RVPROPERTIES_SIZE;
  ------------------
  |  |  281|      0|#define RVPROPERTIES_SIZE  34
  ------------------
 1679|       |
 1680|      0|        cnt = track->private_size - RVPROPERTIES_SIZE;
  ------------------
  |  |  281|      0|#define RVPROPERTIES_SIZE  34
  ------------------
 1681|      0|        uint32_t t2 = AV_RB32(src - 4);
 1682|      0|        switch (t2 == 0x10003000 || t2 == 0x10003001 ? '1' : track->codec_id[9]) {
  ------------------
  |  Branch (1682:17): [True: 0, False: 0]
  |  Branch (1682:17): [True: 0, False: 0]
  |  Branch (1682:37): [True: 0, False: 0]
  ------------------
 1683|      0|        case '1': sh_v->codec = "rv10"; break;
  ------------------
  |  Branch (1683:9): [True: 0, False: 0]
  ------------------
 1684|      0|        case '2': sh_v->codec = "rv20"; break;
  ------------------
  |  Branch (1684:9): [True: 0, False: 0]
  ------------------
 1685|      0|        case '3': sh_v->codec = "rv30"; break;
  ------------------
  |  Branch (1685:9): [True: 0, False: 0]
  ------------------
 1686|      0|        case '4': sh_v->codec = "rv40"; break;
  ------------------
  |  Branch (1686:9): [True: 0, False: 0]
  ------------------
 1687|      0|        }
 1688|       |        // copy type1 and type2 info from rv properties
 1689|      0|        extradata_size = cnt + 8;
 1690|      0|        extradata = src - 8;
 1691|      0|        track->parse = true;
 1692|      0|        track->parse_timebase = 1e3;
 1693|     66|    } else if (strcmp(track->codec_id, "V_UNCOMPRESSED") == 0) {
  ------------------
  |  Branch (1693:16): [True: 0, False: 66]
  ------------------
 1694|       |        // raw video, "like AVI" - this is a FourCC
 1695|      0|        sh_v->codec_tag = track->colorspace;
 1696|      0|        sh_v->codec = "rawvideo";
 1697|     66|    } else if (strcmp(track->codec_id, "V_QUICKTIME") == 0) {
  ------------------
  |  Branch (1697:16): [True: 0, False: 66]
  ------------------
 1698|      0|        if (track->private_size >= 8) {
  ------------------
  |  Branch (1698:13): [True: 0, False: 0]
  ------------------
 1699|      0|            sh_v->codec_tag = AV_RL32(track->private_data + 4);
 1700|      0|            mp_set_codec_from_tag(sh_v);
 1701|       |            // Some non-compliant files have fourcc at offset 0.
 1702|      0|            if (!sh_v->codec) {
  ------------------
  |  Branch (1702:17): [True: 0, False: 0]
  ------------------
 1703|      0|                sh_v->codec_tag = AV_RL32(track->private_data);
 1704|      0|                mp_set_codec_from_tag(sh_v);
 1705|      0|            }
 1706|      0|            extradata = track->private_data;
 1707|      0|            extradata_size = track->private_size;
 1708|      0|        }
 1709|     66|    } else if (strcmp(track->codec_id, "V_VC1") == 0) {
  ------------------
  |  Branch (1709:16): [True: 0, False: 66]
  ------------------
 1710|      0|        if (track->private_size >= 7 && (track->private_data[0] & 0xf0) == 0xc0) {
  ------------------
  |  Branch (1710:13): [True: 0, False: 0]
  |  Branch (1710:41): [True: 0, False: 0]
  ------------------
 1711|      0|            extradata = track->private_data + 7;
 1712|      0|            extradata_size = track->private_size - 7;
 1713|      0|        }
 1714|      0|        sh_v->codec = "vc1";
 1715|     66|    } else {
 1716|  1.45k|        for (int i = 0; mkv_video_tags[i][0]; i++) {
  ------------------
  |  Branch (1716:25): [True: 1.38k, False: 66]
  ------------------
 1717|  1.38k|            if (!strcmp(mkv_video_tags[i][0], track->codec_id)) {
  ------------------
  |  Branch (1717:17): [True: 0, False: 1.38k]
  ------------------
 1718|      0|                sh_v->codec = mkv_video_tags[i][1];
 1719|      0|                break;
 1720|      0|            }
 1721|  1.38k|        }
 1722|     66|        if (track->private_data && track->private_size > 0) {
  ------------------
  |  Branch (1722:13): [True: 41, False: 25]
  |  Branch (1722:36): [True: 41, False: 0]
  ------------------
 1723|     41|            extradata = track->private_data;
 1724|     41|            extradata_size = track->private_size;
 1725|     41|        }
 1726|     66|    }
 1727|       |
 1728|    253|    const char *codec = sh_v->codec ? sh_v->codec : "";
  ------------------
  |  Branch (1728:25): [True: 163, False: 90]
  ------------------
 1729|    253|    if (!strcmp(codec, "mjpeg")) {
  ------------------
  |  Branch (1729:9): [True: 0, False: 253]
  ------------------
 1730|      0|        sh_v->codec_tag = MKTAG('m', 'j', 'p', 'g');
 1731|      0|        track->require_keyframes = true;
 1732|      0|    }
 1733|       |
 1734|    253|    if (extradata_size > 0x1000000) {
  ------------------
  |  Branch (1734:9): [True: 0, False: 253]
  ------------------
 1735|      0|        MP_WARN(demuxer, "Invalid CodecPrivate\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1736|      0|        goto done;
 1737|      0|    }
 1738|       |
 1739|    253|    sh_v->extradata = talloc_memdup(sh_v, extradata, extradata_size);
  ------------------
  |  |   49|    253|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|    253|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|    253|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|    253|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|    253|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1740|    253|    sh_v->extradata_size = extradata_size;
 1741|    253|    if (!sh_v->codec) {
  ------------------
  |  Branch (1741:9): [True: 90, False: 163]
  ------------------
 1742|     90|        MP_WARN(demuxer, "Unknown/unsupported CodecID (%s) or missing/bad "
  ------------------
  |  |   90|     90|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     90|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1743|     90|                "CodecPrivate data (track %d).\n",
 1744|     90|                track->codec_id, track->tnum);
 1745|     90|    }
 1746|    253|    sh_v->fps = track->v_frate;
 1747|    253|    sh_v->disp_w = track->v_width;
 1748|    253|    sh_v->disp_h = track->v_height;
 1749|       |
 1750|    253|    struct mp_rect crop;
 1751|    253|    crop.x0 = track->v_crop_left;
 1752|    253|    crop.y0 = track->v_crop_top;
 1753|    253|    crop.x1 = track->v_width - track->v_crop_right;
 1754|    253|    crop.y1 = track->v_height - track->v_crop_bottom;
 1755|       |
 1756|       |    // Keep the codec crop rect as 0s if we have no cropping since the
 1757|       |    // file may have broken width/height tags.
 1758|    253|    if (track->v_crop_left || track->v_crop_top ||
  ------------------
  |  Branch (1758:9): [True: 0, False: 253]
  |  Branch (1758:31): [True: 1, False: 252]
  ------------------
 1759|    252|        track->v_crop_right || track->v_crop_bottom)
  ------------------
  |  Branch (1759:9): [True: 0, False: 252]
  |  Branch (1759:32): [True: 1, False: 251]
  ------------------
 1760|      2|    {
 1761|      2|        sh_v->crop = crop;
 1762|      2|    }
 1763|       |
 1764|    253|    mkv_demuxer_t *mkv_d = demuxer->priv;
 1765|       |
 1766|       |    // The Matroska specification mandates that the PAR is calculated after
 1767|       |    // cropping. However, most files on the internet do not follow this, as it
 1768|       |    // would make them incompatible with crop-unaware players. Additionally,
 1769|       |    // MKVToolNix does not automatically adjust DisplayWidth/DisplayHeight when
 1770|       |    // cropping metadata is added, so most files created with it also do not
 1771|       |    // follow the specification.
 1772|       |    // See the following links for more information:
 1773|       |    // <https://github.com/ietf-wg-cellar/matroska-specification/pull/947>
 1774|       |    // <https://gitlab.com/mbunkus/mkvtoolnix/-/issues/2389>
 1775|       |    // <https://github.com/mpv-player/mpv/pull/13446>
 1776|    253|    int crop_compat_w = mkv_d->opts->crop_compat ? track->v_width : mp_rect_w(crop);
  ------------------
  |  |  157|    253|#define mp_rect_w(r) ((r).x1 - (r).x0)
  ------------------
  |  Branch (1776:25): [True: 253, False: 0]
  ------------------
 1777|    253|    int crop_compat_h = mkv_d->opts->crop_compat ? track->v_height : mp_rect_h(crop);
  ------------------
  |  |  158|    253|#define mp_rect_h(r) ((r).y1 - (r).y0)
  ------------------
  |  Branch (1777:25): [True: 253, False: 0]
  ------------------
 1778|       |
 1779|    253|    int dw = track->v_dwidth_set ? track->v_dwidth : crop_compat_w;
  ------------------
  |  Branch (1779:14): [True: 167, False: 86]
  ------------------
 1780|    253|    int dh = track->v_dheight_set ? track->v_dheight : crop_compat_h;
  ------------------
  |  Branch (1780:14): [True: 165, False: 88]
  ------------------
 1781|    253|    struct mp_image_params p = {.w = crop_compat_w, .h = crop_compat_h};
 1782|    253|    mp_image_params_set_dsize(&p, dw, dh);
 1783|    253|    sh_v->par_w = p.p_w;
 1784|    253|    sh_v->par_h = p.p_h;
 1785|       |
 1786|    253|    sh_v->stereo_mode = track->stereo_mode;
 1787|    253|    sh_v->repr = track->repr;
 1788|    253|    sh_v->color = track->color;
 1789|    253|    sh_v->chroma_location = track->chroma_location;
 1790|       |
 1791|    253|    if (track->v_projection_pose_roll) {
  ------------------
  |  Branch (1791:9): [True: 0, False: 253]
  ------------------
 1792|      0|        int rotate = lrintf(fmodf(fmodf(-1 * track->v_projection_pose_roll, 360) + 360, 360));
 1793|      0|        sh_v->rotate = rotate;
 1794|      0|    }
 1795|       |
 1796|       |    // our vessel to transport global track side data to decoder context;
 1797|       |    // this gets called in all lavc decoders through `mp_set_avctx_codec_headers`
 1798|       |    // and its failure causes decoding failure. Thus if this call fails here, it is
 1799|       |    // likely that decoding of this track would also lead to an error.
 1800|    253|    struct AVCodecParameters **lavp = talloc_ptrtype(track, lavp);
  ------------------
  |  |   34|    253|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|    253|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    253|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1801|    253|    talloc_set_destructor(lavp, avcodec_par_destructor);
  ------------------
  |  |   41|    253|#define talloc_set_destructor           ta_set_destructor
  ------------------
 1802|    253|    *lavp = sh_v->lav_codecpar = mp_codec_params_to_av(sh_v);
 1803|    253|    if (!sh_v->lav_codecpar) {
  ------------------
  |  Branch (1803:9): [True: 0, False: 253]
  ------------------
 1804|      0|        MP_ERR(demuxer, "Failed to create codec parameters for track %d!",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1805|      0|               track->tnum);
 1806|      0|        goto done;
 1807|      0|    }
 1808|       |
 1809|    253|    if (track->dovi_config) {
  ------------------
  |  Branch (1809:9): [True: 0, False: 253]
  ------------------
 1810|      0|        size_t dovi_size;
 1811|      0|        AVDOVIDecoderConfigurationRecord *dovi = av_dovi_alloc(&dovi_size);
 1812|      0|        MP_HANDLE_OOM(dovi);
  ------------------
  |  |  206|      0|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|      0|        void *oom_p_ = (x);     \
  |  |  208|      0|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  209|      0|            abort();            \
  |  |  210|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1813|       |
 1814|      0|        memcpy(dovi, track->dovi_config, dovi_size);
 1815|       |
 1816|      0|        if (!av_packet_side_data_add(&sh_v->lav_codecpar->coded_side_data,
  ------------------
  |  Branch (1816:13): [True: 0, False: 0]
  ------------------
 1817|      0|                                     &sh_v->lav_codecpar->nb_coded_side_data,
 1818|      0|                                     AV_PKT_DATA_DOVI_CONF,
 1819|      0|                                     dovi, dovi_size, 0))
 1820|      0|        {
 1821|      0|            MP_ERR(demuxer, "Failed to attach Dolby Vision configuration record to "
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1822|      0|                   "codec parameters for track %d!\n", track->tnum);
 1823|      0|            av_free(dovi);
 1824|      0|        }
 1825|       |
 1826|      0|        sh_v->dovi = true;
 1827|      0|        sh_v->dv_level = track->dovi_config->dv_level;
 1828|      0|        sh_v->dv_profile = track->dovi_config->dv_profile;
 1829|      0|        sh_v->dv_el_present = track->dovi_config->bl_present_flag &&
  ------------------
  |  Branch (1829:31): [True: 0, False: 0]
  ------------------
 1830|      0|                              track->dovi_config->el_present_flag;
  ------------------
  |  Branch (1830:31): [True: 0, False: 0]
  ------------------
 1831|      0|    }
 1832|       |
 1833|    253|#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(62, 35, 100)
 1834|    253|    if (track->hvce.len > 0) {
  ------------------
  |  Branch (1834:9): [True: 0, False: 253]
  ------------------
 1835|      0|        void *data = av_memdup(track->hvce.start, track->hvce.len);
 1836|      0|        MP_HANDLE_OOM(data);
  ------------------
  |  |  206|      0|#define MP_HANDLE_OOM(x) do {   \
  |  |  207|      0|        void *oom_p_ = (x);     \
  |  |  208|      0|        if (!oom_p_)            \
  |  |  ------------------
  |  |  |  Branch (208:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  209|      0|            abort();            \
  |  |  210|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (210:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1837|      0|        if (!av_packet_side_data_add(&sh_v->lav_codecpar->coded_side_data,
  ------------------
  |  Branch (1837:13): [True: 0, False: 0]
  ------------------
 1838|      0|                                     &sh_v->lav_codecpar->nb_coded_side_data,
 1839|      0|                                     AV_PKT_DATA_HEVC_CONF,
 1840|      0|                                     data, track->hvce.len, 0))
 1841|      0|        {
 1842|      0|            MP_ERR(demuxer, "Failed to attach hvcE configuration record to "
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1843|      0|                   "codec parameters for track %d!\n", track->tnum);
 1844|      0|            av_free(data);
 1845|      0|        }
 1846|      0|    }
 1847|    253|#endif
 1848|       |
 1849|    259|done:
 1850|    259|    demux_add_sh_stream(demuxer, sh);
 1851|       |
 1852|       |    // Profile 7 NALU-interleaved
 1853|    259|    if (sh_v->dv_el_present)
  ------------------
  |  Branch (1853:9): [True: 0, False: 259]
  ------------------
 1854|      0|        track->dovi_split = mp_dovi_split_create(demuxer, sh);
 1855|       |
 1856|    259|    return 0;
 1857|    253|}
demux_mkv.c:init_track:
 1570|    551|{
 1571|    551|    track->stream = sh;
 1572|       |
 1573|    551|    if (track->language && (strcmp(track->language, "und") != 0))
  ------------------
  |  Branch (1573:9): [True: 551, False: 0]
  |  Branch (1573:28): [True: 551, False: 0]
  ------------------
 1574|    551|        sh->lang = track->language;
 1575|       |
 1576|    551|    sh->ff_index = idx; // Emulate lavf track index. For backward compatibility.
 1577|    551|    sh->demuxer_id = track->tnum;
 1578|    551|    sh->title = track->name;
 1579|    551|    sh->default_track = track->default_track;
 1580|    551|    sh->forced_track = track->forced_track;
 1581|    551|    sh->visual_impaired_track = track->visual_impaired_track;
 1582|    551|    sh->hearing_impaired_track = track->hearing_impaired_track;
 1583|    551|    sh->original_track = track->original_track;
 1584|    551|    sh->commentary_track = track->commentary_track;
 1585|    551|}
demux_mkv.c:avcodec_par_destructor:
 1636|    253|{
 1637|    253|    avcodec_parameters_free(p);
 1638|    253|}
demux_mkv.c:demux_mkv_open_audio:
 1949|    292|{
 1950|    292|    struct sh_stream *sh = demux_alloc_sh_stream(STREAM_AUDIO);
 1951|    292|    init_track(demuxer, track, sh, idx);
 1952|    292|    struct mp_codec_params *sh_a = sh->codec;
 1953|       |
 1954|    292|    if (track->private_size > 0x1000000)
  ------------------
  |  Branch (1954:9): [True: 0, False: 292]
  ------------------
 1955|      0|        goto error;
 1956|       |
 1957|    292|    unsigned char *extradata = track->private_data;
 1958|    292|    unsigned int extradata_len = track->private_size;
 1959|       |
 1960|    292|    if (!track->a_osfreq)
  ------------------
  |  Branch (1960:9): [True: 291, False: 1]
  ------------------
 1961|    291|        track->a_osfreq = track->a_sfreq;
 1962|    292|    sh_a->bits_per_coded_sample = track->a_bps ? track->a_bps : 16;
  ------------------
  |  Branch (1962:35): [True: 0, False: 292]
  ------------------
 1963|    292|    sh_a->samplerate = (uint32_t) track->a_osfreq;
 1964|    292|    mp_chmap_set_unknown(&sh_a->channels, track->a_channels);
 1965|       |
 1966|  5.84k|    for (int i = 0; mkv_audio_tags[i][0]; i++) {
  ------------------
  |  Branch (1966:21): [True: 5.54k, False: 292]
  ------------------
 1967|  5.54k|        if (!strcmp(mkv_audio_tags[i][0], track->codec_id)) {
  ------------------
  |  Branch (1967:13): [True: 0, False: 5.54k]
  ------------------
 1968|      0|            sh_a->codec = mkv_audio_tags[i][1];
 1969|      0|            break;
 1970|      0|        }
 1971|  5.54k|    }
 1972|       |
 1973|    292|    if (!strcmp(track->codec_id, "A_MS/ACM")) { /* AVI compatibility mode */
  ------------------
  |  Branch (1973:9): [True: 263, False: 29]
  ------------------
 1974|       |        // The private_data contains a WAVEFORMATEX struct
 1975|    263|        if (track->private_size < 18)
  ------------------
  |  Branch (1975:13): [True: 257, False: 6]
  ------------------
 1976|    257|            goto error;
 1977|      6|        MP_DBG(demuxer, "track with MS compat audio.\n");
  ------------------
  |  |   93|      6|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      6|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1978|      6|        unsigned char *h = track->private_data;
 1979|      6|        sh_a->codec_tag = AV_RL16(h + 0);         // wFormatTag
 1980|      6|        if (track->a_channels == 0)
  ------------------
  |  Branch (1980:13): [True: 5, False: 1]
  ------------------
 1981|      5|            track->a_channels = AV_RL16(h + 2); // nChannels
 1982|      6|        if (sh_a->samplerate == 0)
  ------------------
  |  Branch (1982:13): [True: 5, False: 1]
  ------------------
 1983|      5|            sh_a->samplerate = AV_RL32(h + 4);  // nSamplesPerSec
 1984|      6|        sh_a->bitrate = AV_RL32(h + 8) * 8;     // nAvgBytesPerSec
 1985|      6|        sh_a->block_align = AV_RL16(h + 12);    // nBlockAlign
 1986|      6|        if (track->a_bps == 0)
  ------------------
  |  Branch (1986:13): [True: 6, False: 0]
  ------------------
 1987|      6|            track->a_bps = AV_RL16(h + 14);     // wBitsPerSample
 1988|      6|        extradata = track->private_data + 18;
 1989|      6|        extradata_len = track->private_size - 18;
 1990|      6|        sh_a->bits_per_coded_sample = track->a_bps;
 1991|      6|        sh_a->extradata = extradata;
 1992|      6|        sh_a->extradata_size = extradata_len;
 1993|      6|        mp_set_codec_from_tag(sh_a);
 1994|      6|        extradata = sh_a->extradata;
 1995|      6|        extradata_len = sh_a->extradata_size;
 1996|     29|    } else if (!strcmp(track->codec_id, "A_PCM/INT/LIT")) {
  ------------------
  |  Branch (1996:16): [True: 0, False: 29]
  ------------------
 1997|      0|        bool sign = sh_a->bits_per_coded_sample > 8;
 1998|      0|        mp_set_pcm_codec(sh_a, sign, false, sh_a->bits_per_coded_sample, false);
 1999|     29|    } else if (!strcmp(track->codec_id, "A_PCM/INT/BIG")) {
  ------------------
  |  Branch (1999:16): [True: 0, False: 29]
  ------------------
 2000|      0|        bool sign = sh_a->bits_per_coded_sample > 8;
 2001|      0|        mp_set_pcm_codec(sh_a, sign, false, sh_a->bits_per_coded_sample, true);
 2002|     29|    } else if (!strcmp(track->codec_id, "A_PCM/FLOAT/IEEE")) {
  ------------------
  |  Branch (2002:16): [True: 0, False: 29]
  ------------------
 2003|      0|        sh_a->codec = sh_a->bits_per_coded_sample == 64 ? "pcm_f64le" : "pcm_f32le";
  ------------------
  |  Branch (2003:23): [True: 0, False: 0]
  ------------------
 2004|     29|    } else if (!strncmp(track->codec_id, "A_REAL/", 7)) {
  ------------------
  |  Branch (2004:16): [True: 0, False: 29]
  ------------------
 2005|      0|        if (track->private_size < RAPROPERTIES4_SIZE)
  ------------------
  |  |  282|      0|#define RAPROPERTIES4_SIZE 56
  ------------------
  |  Branch (2005:13): [True: 0, False: 0]
  ------------------
 2006|      0|            goto error;
 2007|       |        /* Common initialization for all RealAudio codecs */
 2008|      0|        unsigned char *src = track->private_data;
 2009|       |
 2010|      0|        int version = AV_RB16(src + 4);
 2011|      0|        unsigned int flavor = AV_RB16(src + 22);
 2012|      0|        track->coded_framesize = AV_RB32(src + 24);
 2013|      0|        track->sub_packet_h = AV_RB16(src + 40);
 2014|      0|        sh_a->block_align = track->audiopk_size = AV_RB16(src + 42);
 2015|      0|        track->sub_packet_size = AV_RB16(src + 44);
 2016|      0|        int offset = 0;
 2017|      0|        if (version == 4) {
  ------------------
  |  Branch (2017:13): [True: 0, False: 0]
  ------------------
 2018|      0|            offset += RAPROPERTIES4_SIZE;
  ------------------
  |  |  282|      0|#define RAPROPERTIES4_SIZE 56
  ------------------
 2019|      0|            if (offset + 1 > track->private_size)
  ------------------
  |  Branch (2019:17): [True: 0, False: 0]
  ------------------
 2020|      0|                goto error;
 2021|      0|            offset += (src[offset] + 1) * 2 + 3;
 2022|      0|        } else {
 2023|      0|            offset += RAPROPERTIES5_SIZE + 3 + (version == 5 ? 1 : 0);
  ------------------
  |  |  283|      0|#define RAPROPERTIES5_SIZE 70
  ------------------
  |  Branch (2023:49): [True: 0, False: 0]
  ------------------
 2024|      0|        }
 2025|       |
 2026|      0|        if (track->audiopk_size == 0 || track->sub_packet_size == 0 ||
  ------------------
  |  Branch (2026:13): [True: 0, False: 0]
  |  Branch (2026:41): [True: 0, False: 0]
  ------------------
 2027|      0|            track->sub_packet_h == 0 || track->coded_framesize == 0)
  ------------------
  |  Branch (2027:13): [True: 0, False: 0]
  |  Branch (2027:41): [True: 0, False: 0]
  ------------------
 2028|      0|            goto error;
 2029|      0|        if (track->coded_framesize > 0x40000000)
  ------------------
  |  Branch (2029:13): [True: 0, False: 0]
  ------------------
 2030|      0|            goto error;
 2031|       |
 2032|      0|        if (offset + 4 > track->private_size)
  ------------------
  |  Branch (2032:13): [True: 0, False: 0]
  ------------------
 2033|      0|            goto error;
 2034|      0|        uint32_t codecdata_length = AV_RB32(src + offset);
 2035|      0|        offset += 4;
 2036|      0|        if (offset > track->private_size ||
  ------------------
  |  Branch (2036:13): [True: 0, False: 0]
  ------------------
 2037|      0|            codecdata_length > track->private_size - offset)
  ------------------
  |  Branch (2037:13): [True: 0, False: 0]
  ------------------
 2038|      0|            goto error;
 2039|      0|        extradata_len = codecdata_length;
 2040|      0|        extradata = src + offset;
 2041|       |
 2042|      0|        if (!strcmp(track->codec_id, "A_REAL/ATRC")) {
  ------------------
  |  Branch (2042:13): [True: 0, False: 0]
  ------------------
 2043|      0|            sh_a->codec = "atrac3";
 2044|      0|            if (flavor >= MP_ARRAY_SIZE(atrc_fl2bps))
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2044:17): [True: 0, False: 0]
  ------------------
 2045|      0|                goto error;
 2046|      0|            sh_a->bitrate = atrc_fl2bps[flavor] * 8;
 2047|      0|            if (!track->sub_packet_size || track->audiopk_size % track->sub_packet_size)
  ------------------
  |  Branch (2047:17): [True: 0, False: 0]
  |  Branch (2047:44): [True: 0, False: 0]
  ------------------
 2048|      0|                goto error;
 2049|      0|            sh_a->block_align = track->sub_packet_size;
 2050|      0|        } else if (!strcmp(track->codec_id, "A_REAL/COOK")) {
  ------------------
  |  Branch (2050:20): [True: 0, False: 0]
  ------------------
 2051|      0|            sh_a->codec = "cook";
 2052|      0|            if (flavor >= MP_ARRAY_SIZE(cook_fl2bps))
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2052:17): [True: 0, False: 0]
  ------------------
 2053|      0|                goto error;
 2054|      0|            sh_a->bitrate = cook_fl2bps[flavor] * 8;
 2055|      0|            if (!track->sub_packet_size || track->audiopk_size % track->sub_packet_size)
  ------------------
  |  Branch (2055:17): [True: 0, False: 0]
  |  Branch (2055:44): [True: 0, False: 0]
  ------------------
 2056|      0|                goto error;
 2057|      0|            sh_a->block_align = track->sub_packet_size;
 2058|      0|        } else if (!strcmp(track->codec_id, "A_REAL/SIPR")) {
  ------------------
  |  Branch (2058:20): [True: 0, False: 0]
  ------------------
 2059|      0|            sh_a->codec = "sipr";
 2060|      0|            if (flavor >= MP_ARRAY_SIZE(sipr_fl2bps))
  ------------------
  |  |   49|      0|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (2060:17): [True: 0, False: 0]
  ------------------
 2061|      0|                goto error;
 2062|      0|            sh_a->bitrate = sipr_fl2bps[flavor] * 8;
 2063|      0|            sh_a->block_align = track->coded_framesize;
 2064|      0|        } else if (!strcmp(track->codec_id, "A_REAL/28_8")) {
  ------------------
  |  Branch (2064:20): [True: 0, False: 0]
  ------------------
 2065|      0|            sh_a->codec = "ra_288";
 2066|      0|            sh_a->bitrate = 3600 * 8;
 2067|      0|            if (track->sub_packet_h & 1)
  ------------------
  |  Branch (2067:17): [True: 0, False: 0]
  ------------------
 2068|      0|                goto error;
 2069|      0|            if (2 * track->audiopk_size != (int64_t)track->sub_packet_h * track->coded_framesize)
  ------------------
  |  Branch (2069:17): [True: 0, False: 0]
  ------------------
 2070|      0|                goto error;
 2071|      0|            sh_a->block_align = track->coded_framesize;
 2072|      0|        } else if (!strcmp(track->codec_id, "A_REAL/DNET")) {
  ------------------
  |  Branch (2072:20): [True: 0, False: 0]
  ------------------
 2073|      0|            sh_a->codec = "ac3";
 2074|      0|        } else {
 2075|      0|            goto error;
 2076|      0|        }
 2077|       |
 2078|       |        // Limit buffer size to 128 MiB to avoid excessive memory allocation on malformed files.
 2079|      0|        if (track->sub_packet_h * track->audiopk_size > (128 << 20)) {
  ------------------
  |  Branch (2079:13): [True: 0, False: 0]
  ------------------
 2080|      0|            MP_WARN(demuxer, "RealAudio packet size too big (%" PRIu32 " MiB) - skipping track\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__)
  |  |  ------------------
  ------------------
 2081|      0|                    track->sub_packet_h * track->audiopk_size);
 2082|      0|            goto error;
 2083|      0|        }
 2084|       |
 2085|      0|        track->audio_buf =
 2086|      0|            talloc_array_size(track, track->sub_packet_h, track->audiopk_size);
  ------------------
  |  |   32|      0|#define talloc_array_size               ta_xnew_array_size
  |  |  ------------------
  |  |  |  |  137|      0|#define ta_xnew_array_size(...)         ta_oom_p(ta_new_array_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |   86|      0|    ta_alloc_size(ta_parent, ta_calc_array_size(element_size, count))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  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
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2087|      0|        track->audio_timestamp =
 2088|      0|            talloc_array(track, double, track->sub_packet_h);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2089|     29|    } else if (!strncmp(track->codec_id, "A_AAC/", 6)) {
  ------------------
  |  Branch (2089:16): [True: 0, False: 29]
  ------------------
 2090|      0|        sh_a->codec = "aac";
 2091|       |
 2092|       |        /* Recreate the 'private data' (not needed for plain A_AAC) */
 2093|      0|        int srate_idx = aac_get_sample_rate_index(track->a_sfreq);
 2094|      0|        const char *tail = "";
 2095|      0|        if (strlen(track->codec_id) >= 12)
  ------------------
  |  Branch (2095:13): [True: 0, False: 0]
  ------------------
 2096|      0|            tail = &track->codec_id[12];
 2097|      0|        int profile = 3;
 2098|      0|        if (!strncmp(tail, "MAIN", 4))
  ------------------
  |  Branch (2098:13): [True: 0, False: 0]
  ------------------
 2099|      0|            profile = 0;
 2100|      0|        else if (!strncmp(tail, "LC", 2))
  ------------------
  |  Branch (2100:18): [True: 0, False: 0]
  ------------------
 2101|      0|            profile = 1;
 2102|      0|        else if (!strncmp(tail, "SSR", 3))
  ------------------
  |  Branch (2102:18): [True: 0, False: 0]
  ------------------
 2103|      0|            profile = 2;
 2104|      0|        extradata = talloc_size(sh_a, 5);
  ------------------
  |  |   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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2105|      0|        extradata[0] = ((profile + 1) << 3) | ((srate_idx & 0xE) >> 1);
 2106|      0|        extradata[1] = ((srate_idx & 0x1) << 7) | (track->a_channels << 3);
 2107|       |
 2108|      0|        if (strstr(track->codec_id, "SBR") != NULL) {
  ------------------
  |  Branch (2108:13): [True: 0, False: 0]
  ------------------
 2109|       |            /* HE-AAC (aka SBR AAC) */
 2110|      0|            extradata_len = 5;
 2111|       |
 2112|      0|            srate_idx = aac_get_sample_rate_index(sh_a->samplerate);
 2113|      0|            extradata[2] = AAC_SYNC_EXTENSION_TYPE >> 3;
  ------------------
  |  |  305|      0|#define AAC_SYNC_EXTENSION_TYPE 0x02b7
  ------------------
 2114|      0|            extradata[3] = ((AAC_SYNC_EXTENSION_TYPE & 0x07) << 5) | 5;
  ------------------
  |  |  305|      0|#define AAC_SYNC_EXTENSION_TYPE 0x02b7
  ------------------
 2115|      0|            extradata[4] = (1 << 7) | (srate_idx << 3);
 2116|      0|            track->default_duration = 1024.0 / (sh_a->samplerate / 2);
 2117|      0|        } else {
 2118|      0|            extradata_len = 2;
 2119|      0|            track->default_duration = 1024.0 / sh_a->samplerate;
 2120|      0|        }
 2121|     29|    } else if (!strncmp(track->codec_id, "A_AC3/", 6)) {
  ------------------
  |  Branch (2121:16): [True: 0, False: 29]
  ------------------
 2122|      0|        sh_a->codec = "ac3";
 2123|     29|    } else if (!strncmp(track->codec_id, "A_EAC3/", 7)) {
  ------------------
  |  Branch (2123:16): [True: 0, False: 29]
  ------------------
 2124|      0|        sh_a->codec = "eac3";
 2125|      0|    }
 2126|       |
 2127|     35|    if (!sh_a->codec)
  ------------------
  |  Branch (2127:9): [True: 33, False: 2]
  ------------------
 2128|     33|        goto error;
 2129|       |
 2130|      2|    const char *codec = sh_a->codec;
 2131|      2|    if (!strcmp(codec, "mp1") || !strcmp(codec, "mp2") || !strcmp(codec, "mp3") ||
  ------------------
  |  Branch (2131:9): [True: 0, False: 2]
  |  Branch (2131:34): [True: 0, False: 2]
  |  Branch (2131:59): [True: 0, False: 2]
  ------------------
 2132|      2|        !strcmp(codec, "truehd") || !strcmp(codec, "eac3"))
  ------------------
  |  Branch (2132:9): [True: 0, False: 2]
  |  Branch (2132:37): [True: 0, False: 2]
  ------------------
 2133|      0|    {
 2134|      0|        mkv_demuxer_t *mkv_d = demuxer->priv;
 2135|      0|        int64_t segment_timebase = (1e9 / mkv_d->tc_scale);
 2136|       |
 2137|      0|        track->parse = true;
 2138|      0|        track->parse_timebase = MPMAX(sh_a->samplerate, segment_timebase);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2139|      2|    } else if (!strcmp(codec, "flac")) {
  ------------------
  |  Branch (2139:16): [True: 0, False: 2]
  ------------------
 2140|      0|        unsigned char *ptr = extradata;
 2141|      0|        unsigned int size = extradata_len;
 2142|      0|        if (size < 4 || ptr[0] != 'f' || ptr[1] != 'L' || ptr[2] != 'a'
  ------------------
  |  Branch (2142:13): [True: 0, False: 0]
  |  Branch (2142:25): [True: 0, False: 0]
  |  Branch (2142:42): [True: 0, False: 0]
  |  Branch (2142:59): [True: 0, False: 0]
  ------------------
 2143|      0|            || ptr[3] != 'C') {
  ------------------
  |  Branch (2143:16): [True: 0, False: 0]
  ------------------
 2144|      0|            extradata = talloc_size(sh_a, 4);
  ------------------
  |  |   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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2145|      0|            extradata_len = 4;
 2146|      0|            memcpy(extradata, "fLaC", 4);
 2147|      0|        }
 2148|      0|        parse_flac_chmap(&sh_a->channels, extradata, extradata_len);
 2149|      2|    } else if (!strcmp(codec, "alac")) {
  ------------------
  |  Branch (2149:16): [True: 0, False: 2]
  ------------------
 2150|      0|        if (track->private_size) {
  ------------------
  |  Branch (2150:13): [True: 0, False: 0]
  ------------------
 2151|      0|            extradata_len = track->private_size + 12;
 2152|      0|            extradata = talloc_size(sh_a, extradata_len);
  ------------------
  |  |   43|      0|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|      0|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|      0|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2153|      0|            char *data = extradata;
 2154|      0|            AV_WB32(data + 0, extradata_len);
 2155|      0|            memcpy(data + 4, "alac", 4);
 2156|      0|            AV_WB32(data + 8, 0);
 2157|      0|            memcpy(data + 12, track->private_data, track->private_size);
 2158|      0|        }
 2159|      2|    } else if (!strcmp(codec, "tta")) {
  ------------------
  |  Branch (2159:16): [True: 0, False: 2]
  ------------------
 2160|      0|        extradata_len = 30;
 2161|      0|        extradata = talloc_zero_size(sh_a, extradata_len);
  ------------------
  |  |   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
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2162|      0|        if (!extradata)
  ------------------
  |  Branch (2162:13): [True: 0, False: 0]
  ------------------
 2163|      0|            goto error;
 2164|      0|        char *data = extradata;
 2165|      0|        memcpy(data + 0, "TTA1", 4);
 2166|      0|        AV_WL16(data + 4, 1);
 2167|      0|        AV_WL16(data + 6, sh_a->channels.num);
 2168|      0|        AV_WL16(data + 8, sh_a->bits_per_coded_sample);
 2169|      0|        AV_WL32(data + 10, track->a_osfreq);
 2170|      0|        mkv_demuxer_t *mkv_d = demuxer->priv;
 2171|      0|        double samples = mkv_d->duration * track->a_osfreq;
 2172|      0|        AV_WL32(data + 14, samples > 0 ? MPMIN(samples, UINT32_MAX) : 0);
  ------------------
  |  Branch (2172:9): [True: 0, False: 0]
  |  Branch (2172:9): [True: 0, False: 0]
  ------------------
 2173|      2|    } else if (!strcmp(codec, "opus")) {
  ------------------
  |  Branch (2173:16): [True: 0, False: 2]
  ------------------
 2174|       |        // Hardcode the rate libavcodec's opus decoder outputs, so that
 2175|       |        // AV_PKT_DATA_SKIP_SAMPLES actually works. The Matroska header only
 2176|       |        // has an arbitrary "input" samplerate, while libavcodec is fixed to
 2177|       |        // output 48000.
 2178|      0|        sh_a->samplerate = 48000;
 2179|      2|    } else if (!strcmp(codec, "atrac1")) {
  ------------------
  |  Branch (2179:16): [True: 0, False: 2]
  ------------------
 2180|      0|        if (sh_a->channels.num > 8)
  ------------------
  |  Branch (2180:13): [True: 0, False: 0]
  ------------------
 2181|      0|            goto error;
 2182|       |        // ATRAC1 uses a constant frame size.
 2183|      0|        sh_a->block_align = sh_a->channels.num * 212;
 2184|      0|    }
 2185|       |
 2186|       |    // Some files have broken default DefaultDuration set, which will lead to
 2187|       |    // audio packets with incorrect timestamps. This follows FFmpeg commit
 2188|       |    // 6158a3b, sample see FFmpeg ticket 2508.
 2189|      2|    if (sh_a->samplerate == 8000 && strcmp(codec, "ac3") == 0)
  ------------------
  |  Branch (2189:9): [True: 0, False: 2]
  |  Branch (2189:37): [True: 0, False: 0]
  ------------------
 2190|      0|        track->default_duration = 0;
 2191|       |
 2192|       |    // Deal with some FFmpeg-produced garbage, and assume all audio codecs can
 2193|       |    // start decoding from anywhere.
 2194|      2|    if (strcmp(codec, "truehd") != 0)
  ------------------
  |  Branch (2194:9): [True: 2, False: 0]
  ------------------
 2195|      2|        track->require_keyframes = true;
 2196|       |
 2197|      2|    sh_a->extradata = extradata;
 2198|      2|    sh_a->extradata_size = extradata_len;
 2199|       |
 2200|      2|    sh->seek_preroll = track->codec_delay;
 2201|       |
 2202|      2|    demux_add_sh_stream(demuxer, sh);
 2203|       |
 2204|      2|    return 0;
 2205|       |
 2206|    290| error:
 2207|    290|    MP_WARN(demuxer, "Unknown/unsupported audio "
  ------------------
  |  |   90|    290|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    290|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2208|    290|            "codec ID '%s' for track %u or missing/faulty\n"
 2209|    290|            "private codec data.\n", track->codec_id, track->tnum);
 2210|    290|    demux_add_sh_stream(demuxer, sh); // add it anyway
 2211|    290|    return 1;
 2212|      2|}
demux_mkv.c:pair_dovi_tracks:
 2301|    545|{
 2302|    545|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2303|    545|    mkv_track_t *bl_track = NULL, *el_track = NULL;
 2304|       |
 2305|  1.12k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (2305:21): [True: 579, False: 545]
  ------------------
 2306|    579|        mkv_track_t *track = mkv_d->tracks[i];
 2307|    579|        if (!track->stream || track->stream->type != STREAM_VIDEO ||
  ------------------
  |  Branch (2307:13): [True: 28, False: 551]
  |  Branch (2307:31): [True: 292, False: 259]
  ------------------
 2308|    259|            !track->codec_id || strcmp(track->codec_id, "V_MPEGH/ISO/HEVC"))
  ------------------
  |  Branch (2308:13): [True: 0, False: 259]
  |  Branch (2308:33): [True: 259, False: 0]
  ------------------
 2309|    579|            continue;
 2310|       |
 2311|      0|        AVDOVIDecoderConfigurationRecord *dovi = track->dovi_config;
 2312|      0|        if (dovi && dovi->dv_profile == 7 && dovi->el_present_flag) {
  ------------------
  |  Branch (2312:13): [True: 0, False: 0]
  |  Branch (2312:21): [True: 0, False: 0]
  |  Branch (2312:46): [True: 0, False: 0]
  ------------------
 2313|       |            // bl_present_flag is not checked, because the files in the
 2314|       |            // wild set it to 1 for EL stream, while the expectation, based
 2315|       |            // on Dolby spec for MPEG-TS would be that it's set to 0.
 2316|       |            // Ignore this, if we have EL track and single other video track
 2317|       |            // it's safe to assume it's BL.
 2318|      0|            if (el_track)
  ------------------
  |  Branch (2318:17): [True: 0, False: 0]
  ------------------
 2319|      0|                return;
 2320|      0|            el_track = track;
 2321|      0|            continue;
 2322|      0|        }
 2323|       |
 2324|      0|        if (bl_track)
  ------------------
  |  Branch (2324:13): [True: 0, False: 0]
  ------------------
 2325|      0|            return;
 2326|      0|        bl_track = track;
 2327|      0|    }
 2328|       |
 2329|    545|    if (!el_track || !bl_track)
  ------------------
  |  Branch (2329:9): [True: 545, False: 0]
  |  Branch (2329:22): [True: 0, False: 0]
  ------------------
 2330|    545|        return;
 2331|       |
 2332|      0|    struct sh_stream *bl_sh = bl_track->stream;
 2333|      0|    struct sh_stream *el_sh = el_track->stream;
 2334|       |
 2335|       |    // Group storage is attached to the BL so its lifetime tracks the demuxer.
 2336|      0|    struct sh_stream_group *group = talloc_zero(bl_sh, struct sh_stream_group);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2337|      0|    MP_TARRAY_APPEND(group, group->members, group->num_members, bl_sh);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2338|      0|    MP_TARRAY_APPEND(group, group->members, group->num_members, el_sh);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2339|       |
 2340|      0|    bl_sh->group = group;
 2341|      0|    el_sh->group = group;
 2342|       |    el_sh->dependent_track = true;
 2343|      0|}
demux_mkv.c:add_coverart:
 1547|    545|{
 1548|    545|    for (int n = 0; n < demuxer->num_attachments; n++) {
  ------------------
  |  Branch (1548:21): [True: 0, False: 545]
  ------------------
 1549|      0|        struct demux_attachment *att = &demuxer->attachments[n];
 1550|      0|        const char *codec = mp_map_mimetype_to_video_codec(att->type);
 1551|      0|        if (!codec)
  ------------------
  |  Branch (1551:13): [True: 0, False: 0]
  ------------------
 1552|      0|            continue;
 1553|      0|        struct sh_stream *sh = demux_alloc_sh_stream(STREAM_VIDEO);
 1554|      0|        sh->codec->codec = codec;
 1555|      0|        sh->attached_picture = new_demux_packet_from(demuxer->packet_pool,
 1556|      0|                                                     att->data, att->data_size);
 1557|      0|        if (sh->attached_picture) {
  ------------------
  |  Branch (1557:13): [True: 0, False: 0]
  ------------------
 1558|      0|            sh->attached_picture->pts = 0;
 1559|      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)
  |  |  ------------------
  ------------------
 1560|      0|            sh->attached_picture->keyframe = true;
 1561|       |            sh->image = true;
 1562|      0|        }
 1563|      0|        sh->title = att->name;
 1564|      0|        demux_add_sh_stream(demuxer, sh);
 1565|      0|    }
 1566|    545|}
demux_mkv.c:process_tags:
 1314|    545|{
 1315|    545|    struct mkv_demuxer *mkv_d = demuxer->priv;
 1316|    545|    struct ebml_tags *tags = mkv_d->tags;
 1317|       |
 1318|    545|    if (!tags)
  ------------------
  |  Branch (1318:9): [True: 545, False: 0]
  ------------------
 1319|    545|        return;
 1320|       |
 1321|      0|    for (int i = 0; i < tags->n_tag; i++) {
  ------------------
  |  Branch (1321:21): [True: 0, False: 0]
  ------------------
 1322|      0|        struct ebml_tag tag = tags->tag[i];
 1323|      0|        struct mp_tags *dst = NULL;
 1324|       |
 1325|      0|        if (tag.targets.target_chapter_uid) {
  ------------------
  |  Branch (1325:13): [True: 0, False: 0]
  ------------------
 1326|      0|            for (int n = 0; n < demuxer->num_chapters; n++) {
  ------------------
  |  Branch (1326:29): [True: 0, False: 0]
  ------------------
 1327|      0|                if (demuxer->chapters[n].demuxer_id ==
  ------------------
  |  Branch (1327:21): [True: 0, False: 0]
  ------------------
 1328|      0|                    tag.targets.target_chapter_uid)
 1329|      0|                {
 1330|      0|                    dst = demuxer->chapters[n].metadata;
 1331|      0|                    break;
 1332|      0|                }
 1333|      0|            }
 1334|      0|        } else if (tag.targets.target_edition_uid) {
  ------------------
  |  Branch (1334:20): [True: 0, False: 0]
  ------------------
 1335|      0|            for (int n = 0; n < demuxer->num_editions; n++) {
  ------------------
  |  Branch (1335:29): [True: 0, False: 0]
  ------------------
 1336|      0|                if (demuxer->editions[n].demuxer_id ==
  ------------------
  |  Branch (1336:21): [True: 0, False: 0]
  ------------------
 1337|      0|                    tag.targets.target_edition_uid)
 1338|      0|                {
 1339|      0|                    dst = demuxer->editions[n].metadata;
 1340|      0|                    break;
 1341|      0|                }
 1342|      0|            }
 1343|      0|        } else if (tag.targets.target_track_uid) {
  ------------------
  |  Branch (1343:20): [True: 0, False: 0]
  ------------------
 1344|      0|            for (int n = 0; n < mkv_d->num_tracks; n++) {
  ------------------
  |  Branch (1344:29): [True: 0, False: 0]
  ------------------
 1345|      0|                if (mkv_d->tracks[n]->uid ==
  ------------------
  |  Branch (1345:21): [True: 0, False: 0]
  ------------------
 1346|      0|                    tag.targets.target_track_uid)
 1347|      0|                {
 1348|      0|                    struct sh_stream *sh = mkv_d->tracks[n]->stream;
 1349|      0|                    if (sh)
  ------------------
  |  Branch (1349:25): [True: 0, False: 0]
  ------------------
 1350|      0|                        dst = sh->tags;
 1351|      0|                    break;
 1352|      0|                }
 1353|      0|            }
 1354|      0|        } else if (tag.targets.target_attachment_uid) {
  ------------------
  |  Branch (1354:20): [True: 0, False: 0]
  ------------------
 1355|       |            /* ignore */
 1356|      0|        } else {
 1357|      0|            dst = demuxer->metadata;
 1358|      0|        }
 1359|       |
 1360|      0|        if (dst) {
  ------------------
  |  Branch (1360:13): [True: 0, False: 0]
  ------------------
 1361|      0|            for (int j = 0; j < tag.n_simple_tag; j++) {
  ------------------
  |  Branch (1361:29): [True: 0, False: 0]
  ------------------
 1362|      0|                if (tag.simple_tag[j].tag_name && tag.simple_tag[j].tag_string) {
  ------------------
  |  Branch (1362:21): [True: 0, False: 0]
  |  Branch (1362:51): [True: 0, False: 0]
  ------------------
 1363|      0|                    char *name = tag.simple_tag[j].tag_name;
 1364|      0|                    char *val = tag.simple_tag[j].tag_string;
 1365|      0|                    char *old = mp_tags_get_str(dst, name);
 1366|      0|                    if (old)
  ------------------
  |  Branch (1366:25): [True: 0, False: 0]
  ------------------
 1367|      0|                        val = talloc_asprintf(NULL, "%s / %s", old, val);
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1368|      0|                    mp_tags_set_str(dst, name, val);
 1369|      0|                    if (old)
  ------------------
  |  Branch (1369:25): [True: 0, False: 0]
  ------------------
 1370|      0|                        talloc_free(val);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1371|      0|                }
 1372|      0|            }
 1373|      0|        }
 1374|      0|    }
 1375|      0|}
demux_mkv.c:probe_first_timestamp:
 3775|    545|{
 3776|    545|    mkv_demuxer_t *mkv_d = demuxer->priv;
 3777|       |
 3778|    545|    if (!mkv_d->opts->probe_start_time)
  ------------------
  |  Branch (3778:9): [True: 0, False: 545]
  ------------------
 3779|      0|        return;
 3780|       |
 3781|    545|    read_next_block_into_queue(demuxer);
 3782|       |
 3783|    545|    demuxer->start_time = mkv_d->cluster_tc / 1e9;
 3784|       |
 3785|    545|    if (demuxer->start_time)
  ------------------
  |  Branch (3785:9): [True: 10, False: 535]
  ------------------
 3786|    545|        MP_VERBOSE(demuxer, "Start PTS: %f\n", demuxer->start_time);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 3787|    545|}
demux_mkv.c:read_next_block_into_queue:
 3337|  1.17k|{
 3338|  1.17k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3339|  1.17k|    stream_t *s = demuxer->stream;
 3340|  1.17k|    struct block_info block = {0};
 3341|       |
 3342|  4.99k|    while (1) {
  ------------------
  |  Branch (3342:12): [True: 4.99k, Folded]
  ------------------
 3343|  14.6k|        while (stream_tell(s) < mkv_d->cluster_end) {
  ------------------
  |  Branch (3343:16): [True: 13.8k, False: 723]
  ------------------
 3344|  13.8k|            int64_t start_filepos = stream_tell(s);
 3345|  13.8k|            switch (ebml_read_id(s)) {
 3346|  3.39k|            case MATROSKA_ID_TIMECODE: {
  ------------------
  |  |   29|  3.39k|#define MATROSKA_ID_TIMECODE                     0xe7
  ------------------
  |  Branch (3346:13): [True: 3.39k, False: 10.5k]
  ------------------
 3347|  3.39k|                uint64_t num;
 3348|       |                // Block timestamps add up to INT16_MAX ticks to this.
 3349|  3.39k|                if (!ebml_read_uint(s, &num) || num > INT64_MAX / mkv_d->tc_scale - INT16_MAX)
  ------------------
  |  Branch (3349:21): [True: 133, False: 3.26k]
  |  Branch (3349:49): [True: 1, False: 3.26k]
  ------------------
 3350|    134|                    goto find_next_cluster;
 3351|  3.26k|                mkv_d->cluster_tc = num * mkv_d->tc_scale;
 3352|  3.26k|                break;
 3353|  3.39k|            }
 3354|       |
 3355|  1.59k|            case MATROSKA_ID_BLOCKGROUP: {
  ------------------
  |  |   30|  1.59k|#define MATROSKA_ID_BLOCKGROUP                   0xa0
  ------------------
  |  Branch (3355:13): [True: 1.59k, False: 12.3k]
  ------------------
 3356|  1.59k|                uint64_t end = ebml_read_length(s);
 3357|  1.59k|                if (end == EBML_UINT_INVALID)
  ------------------
  |  |   85|  1.59k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (3357:21): [True: 37, False: 1.55k]
  ------------------
 3358|     37|                    goto find_next_cluster;
 3359|  1.55k|                end += stream_tell(s);
 3360|  1.55k|                if (end > mkv_d->cluster_end)
  ------------------
  |  Branch (3360:21): [True: 25, False: 1.53k]
  ------------------
 3361|     25|                    goto find_next_cluster;
 3362|  1.53k|                int res = read_block_group(demuxer, end, &block);
 3363|  1.53k|                if (res > 0)
  ------------------
  |  Branch (3363:21): [True: 0, False: 1.53k]
  ------------------
 3364|      0|                    goto add_block;
 3365|  1.53k|                free_block(&block);
 3366|  1.53k|                if (res < 0)
  ------------------
  |  Branch (3366:21): [True: 1.45k, False: 84]
  ------------------
 3367|  1.45k|                    goto find_next_cluster;
 3368|     84|                break;
 3369|  1.53k|            }
 3370|       |
 3371|  1.63k|            case MATROSKA_ID_SIMPLEBLOCK: {
  ------------------
  |  |   39|  1.63k|#define MATROSKA_ID_SIMPLEBLOCK                  0xa3
  ------------------
  |  Branch (3371:13): [True: 1.63k, False: 12.2k]
  ------------------
 3372|  1.63k|                block = (struct block_info){ .simple = true };
 3373|  1.63k|                int res = read_block(demuxer, mkv_d->cluster_end, &block);
 3374|  1.63k|                if (res > 0)
  ------------------
  |  Branch (3374:21): [True: 456, False: 1.17k]
  ------------------
 3375|    456|                    goto add_block;
 3376|  1.17k|                free_block(&block);
 3377|  1.17k|                if (res < 0)
  ------------------
  |  Branch (3377:21): [True: 1.04k, False: 130]
  ------------------
 3378|  1.04k|                    goto find_next_cluster;
 3379|    130|                break;
 3380|  1.17k|            }
 3381|       |
 3382|    130|            case MATROSKA_ID_CLUSTER:
  ------------------
  |  |   28|     38|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (3382:13): [True: 38, False: 13.8k]
  ------------------
 3383|     38|                mkv_d->cluster_start = start_filepos;
 3384|     38|                goto next_cluster;
 3385|       |
 3386|    740|            case EBML_ID_INVALID:
  ------------------
  |  |   75|    740|#define EBML_ID_INVALID 0xffffffff
  ------------------
  |  Branch (3386:13): [True: 740, False: 13.1k]
  ------------------
 3387|    740|                goto find_next_cluster;
 3388|       |
 3389|  6.49k|            default: ;
  ------------------
  |  Branch (3389:13): [True: 6.49k, False: 7.40k]
  ------------------
 3390|  6.49k|                if (ebml_read_skip(demuxer->log, mkv_d->cluster_end, s) != 0)
  ------------------
  |  Branch (3390:21): [True: 348, False: 6.14k]
  ------------------
 3391|    348|                    goto find_next_cluster;
 3392|  6.14k|                break;
 3393|  13.8k|            }
 3394|  13.8k|        }
 3395|       |
 3396|  4.50k|    find_next_cluster:
 3397|  4.50k|        mkv_d->cluster_end = 0;
 3398|  8.19k|        for (;;) {
 3399|  8.19k|            mkv_d->cluster_start = stream_tell(s);
 3400|  8.19k|            uint32_t id = ebml_read_id(s);
 3401|  8.19k|            if (id == MATROSKA_ID_CLUSTER)
  ------------------
  |  |   28|  8.19k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (3401:17): [True: 3.78k, False: 4.40k]
  ------------------
 3402|  3.78k|                break;
 3403|  4.40k|            if (s->eof)
  ------------------
  |  Branch (3403:17): [True: 713, False: 3.69k]
  ------------------
 3404|    713|                return -1;
 3405|  3.69k|            if (demux_cancel_test(demuxer))
  ------------------
  |  Branch (3405:17): [True: 0, False: 3.69k]
  ------------------
 3406|      0|                return -1;
 3407|  3.69k|            if (id == EBML_ID_EBML && stream_tell(s) >= mkv_d->segment_end) {
  ------------------
  |  |    3|  7.38k|#define EBML_ID_EBML                             0x1a45dfa3
  ------------------
  |  Branch (3407:17): [True: 51, False: 3.63k]
  |  Branch (3407:39): [True: 3, False: 48]
  ------------------
 3408|       |                // Appended segment - don't use its clusters, consider this EOF.
 3409|      3|                stream_seek(s, stream_tell(s) - 4);
 3410|      3|                return -1;
 3411|      3|            }
 3412|       |            // For the sake of robustness, consider even unknown level 1
 3413|       |            // elements the same as unknown/broken IDs.
 3414|  3.68k|            if ((!ebml_is_mkv_level1_id(id) && id != EBML_ID_VOID) ||
  ------------------
  |  |   12|  3.58k|#define EBML_ID_VOID                             0xec
  ------------------
  |  Branch (3414:18): [True: 3.58k, False: 103]
  |  Branch (3414:48): [True: 3.58k, False: 1]
  ------------------
 3415|    104|                ebml_read_skip(demuxer->log, -1, s) != 0)
  ------------------
  |  Branch (3415:17): [True: 15, False: 89]
  ------------------
 3416|  3.59k|            {
 3417|  3.59k|                stream_seek(s, mkv_d->cluster_start);
 3418|  3.59k|                ebml_resync_cluster(demuxer->log, s);
 3419|  3.59k|            }
 3420|  3.68k|        }
 3421|  3.82k|    next_cluster:
 3422|  3.82k|        mkv_d->cluster_end = ebml_read_length(s);
 3423|       |        // mkv files for "streaming" can have this legally
 3424|  3.82k|        if (mkv_d->cluster_end != EBML_UINT_INVALID)
  ------------------
  |  |   85|  3.82k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (3424:13): [True: 3.77k, False: 51]
  ------------------
 3425|  3.77k|            mkv_d->cluster_end += stream_tell(s);
 3426|  3.82k|    }
 3427|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (3427:5): [Folded, False: 0]
  ------------------
 3428|       |
 3429|    456|add_block:
 3430|    456|    index_block(demuxer, &block);
 3431|    456|    MP_TARRAY_APPEND(mkv_d, mkv_d->blocks, mkv_d->num_blocks, block);
  ------------------
  |  |  105|    456|    do {                                            \
  |  |  106|    456|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|    456|    do {                                            \
  |  |  |  |   97|    456|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|    456|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|    456|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|    456|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 153, False: 303]
  |  |  |  |  ------------------
  |  |  |  |   99|    456|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|    153|    do {                                                        \
  |  |  |  |  |  |   89|    153|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|    153|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|    153|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|    153|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|    153|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|    153|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|    153|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 153]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|    456|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 456]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|    456|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|    456|        (idxvar)++;                                 \
  |  |  109|    456|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 456]
  |  |  ------------------
  ------------------
 3432|    456|    return 1;
 3433|      0|}
demux_mkv.c:read_block_group:
 3270|  1.53k|{
 3271|  1.53k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3272|  1.53k|    stream_t *s = demuxer->stream;
 3273|  1.53k|    *block = (struct block_info){ .keyframe = true };
 3274|       |
 3275|  1.68k|    while (stream_tell(s) < end) {
  ------------------
  |  Branch (3275:12): [True: 1.59k, False: 84]
  ------------------
 3276|  1.59k|        switch (ebml_read_id(s)) {
 3277|     12|        case MATROSKA_ID_BLOCKDURATION:;
  ------------------
  |  |   32|     12|#define MATROSKA_ID_BLOCKDURATION                0x9b
  ------------------
  |  Branch (3277:9): [True: 12, False: 1.58k]
  ------------------
 3278|     12|            uint64_t duration;
 3279|     12|            if (!ebml_read_uint(s, &duration))
  ------------------
  |  Branch (3279:17): [True: 12, False: 0]
  ------------------
 3280|     12|                goto error;
 3281|      0|            if (duration <= INT64_MAX / mkv_d->tc_scale) {
  ------------------
  |  Branch (3281:17): [True: 0, False: 0]
  ------------------
 3282|      0|                block->duration = duration * mkv_d->tc_scale;
 3283|      0|                block->duration_known = true;
 3284|      0|            }
 3285|      0|            break;
 3286|       |
 3287|      0|        case MATROSKA_ID_DISCARDPADDING:
  ------------------
  |  |   34|      0|#define MATROSKA_ID_DISCARDPADDING               0x75a2
  ------------------
  |  Branch (3287:9): [True: 0, False: 1.59k]
  ------------------
 3288|      0|            if (!ebml_read_int(s, &block->discardpadding))
  ------------------
  |  Branch (3288:17): [True: 0, False: 0]
  ------------------
 3289|      0|                goto error;
 3290|      0|            break;
 3291|       |
 3292|     14|        case MATROSKA_ID_BLOCK:
  ------------------
  |  |   31|     14|#define MATROSKA_ID_BLOCK                        0xa1
  ------------------
  |  Branch (3292:9): [True: 14, False: 1.58k]
  ------------------
 3293|     14|            if (read_block(demuxer, end, block) < 0)
  ------------------
  |  Branch (3293:17): [True: 1, False: 13]
  ------------------
 3294|      1|                goto error;
 3295|     13|            break;
 3296|       |
 3297|     19|        case MATROSKA_ID_REFERENCEBLOCK:;
  ------------------
  |  |   33|     19|#define MATROSKA_ID_REFERENCEBLOCK               0xfb
  ------------------
  |  Branch (3297:9): [True: 19, False: 1.58k]
  ------------------
 3298|     19|            int64_t num;
 3299|     19|            if (!ebml_read_int(s, &num))
  ------------------
  |  Branch (3299:17): [True: 19, False: 0]
  ------------------
 3300|     19|                goto error;
 3301|      0|            block->keyframe = false;
 3302|      0|            break;
 3303|       |
 3304|      0|        case MATROSKA_ID_BLOCKADDITIONS:;
  ------------------
  |  |   35|      0|#define MATROSKA_ID_BLOCKADDITIONS               0x75a1
  ------------------
  |  Branch (3304:9): [True: 0, False: 1.59k]
  ------------------
 3305|      0|            struct ebml_block_additions additions = {0};
 3306|      0|            struct ebml_parse_ctx parse_ctx = {demuxer->log};
 3307|      0|            if (ebml_read_element(s, &parse_ctx, &additions,
  ------------------
  |  Branch (3307:17): [True: 0, False: 0]
  ------------------
 3308|      0|                                  &ebml_block_additions_desc) < 0)
 3309|      0|                return -1;
 3310|      0|            if (additions.n_block_more > 0 && !block->additions) {
  ------------------
  |  Branch (3310:17): [True: 0, False: 0]
  |  Branch (3310:47): [True: 0, False: 0]
  ------------------
 3311|      0|                block->additions = talloc_dup(NULL, &additions);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3312|      0|                talloc_steal(block->additions, parse_ctx.talloc_ctx);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 3313|      0|                parse_ctx.talloc_ctx = NULL;
 3314|      0|            }
 3315|      0|            talloc_free(parse_ctx.talloc_ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 3316|      0|            break;
 3317|       |
 3318|      5|        case MATROSKA_ID_CLUSTER:
  ------------------
  |  |   28|      5|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (3318:9): [True: 5, False: 1.59k]
  ------------------
 3319|  1.22k|        case EBML_ID_INVALID:
  ------------------
  |  |   75|  1.22k|#define EBML_ID_INVALID 0xffffffff
  ------------------
  |  Branch (3319:9): [True: 1.21k, False: 384]
  ------------------
 3320|  1.22k|            goto error;
 3321|       |
 3322|    334|        default:
  ------------------
  |  Branch (3322:9): [True: 334, False: 1.26k]
  ------------------
 3323|    334|            if (ebml_read_skip(demuxer->log, end, s) != 0)
  ------------------
  |  Branch (3323:17): [True: 198, False: 136]
  ------------------
 3324|    198|                goto error;
 3325|    136|            break;
 3326|  1.59k|        }
 3327|  1.59k|    }
 3328|       |
 3329|     84|    return block->num_laces ? 1 : 0;
  ------------------
  |  Branch (3329:12): [True: 0, False: 84]
  ------------------
 3330|       |
 3331|  1.45k|error:
 3332|  1.45k|    free_block(block);
 3333|  1.45k|    return -1;
 3334|  1.53k|}
demux_mkv.c:free_block:
 3051|  7.40k|{
 3052|  30.0k|    for (int n = 0; n < block->num_laces; n++)
  ------------------
  |  Branch (3052:21): [True: 22.6k, False: 7.40k]
  ------------------
 3053|  22.6k|        av_buffer_unref(&block->laces[n]);
 3054|  7.40k|    block->num_laces = 0;
 3055|       |    TA_FREEP(&block->additions);
  ------------------
  |  |   81|  7.40k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  7.40k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 7.40k]
  |  |  ------------------
  ------------------
 3056|  7.40k|}
demux_mkv.c:read_block:
 3069|  1.64k|{
 3070|  1.64k|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3071|  1.64k|    stream_t *s = demuxer->stream;
 3072|  1.64k|    uint64_t num;
 3073|  1.64k|    int16_t time;
 3074|  1.64k|    uint64_t length;
 3075|       |
 3076|  1.64k|    free_block(block);
 3077|  1.64k|    length = ebml_read_length(s);
 3078|  1.64k|    if (!length || length > 500000000 || stream_tell(s) + length > (uint64_t)end)
  ------------------
  |  Branch (3078:9): [True: 0, False: 1.64k]
  |  Branch (3078:20): [True: 21, False: 1.62k]
  |  Branch (3078:42): [True: 22, False: 1.60k]
  ------------------
 3079|     43|        return -1;
 3080|       |
 3081|  1.60k|    uint64_t endpos = stream_tell(s) + length;
 3082|  1.60k|    int res = -1;
 3083|       |
 3084|       |    // Parse header of the Block element
 3085|       |    /* first byte(s): track num */
 3086|  1.60k|    num = ebml_read_length(s);
 3087|  1.60k|    if (num == EBML_UINT_INVALID || stream_tell(s) >= endpos)
  ------------------
  |  |   85|  3.20k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (3087:9): [True: 75, False: 1.52k]
  |  Branch (3087:37): [True: 160, False: 1.36k]
  ------------------
 3088|    235|        goto exit;
 3089|       |
 3090|       |    /* time (relative to cluster time) */
 3091|  1.36k|    if (stream_tell(s) + 3 > endpos)
  ------------------
  |  Branch (3091:9): [True: 63, False: 1.30k]
  ------------------
 3092|     63|        goto exit;
 3093|  1.30k|    uint8_t c1 = stream_read_char(s);
 3094|  1.30k|    uint8_t c2 = stream_read_char(s);
 3095|  1.30k|    time = c1 << 8 | c2;
 3096|       |
 3097|  1.30k|    uint8_t header_flags = stream_read_char(s);
 3098|       |
 3099|  1.30k|    block->filepos = stream_tell(s);
 3100|       |
 3101|  1.30k|    int lace_type = (header_flags >> 1) & 0x03;
 3102|  1.30k|    if (demux_mkv_read_block_lacing(block, lace_type, s, endpos))
  ------------------
  |  Branch (3102:9): [True: 706, False: 599]
  ------------------
 3103|    706|        goto exit;
 3104|       |
 3105|    599|    if (block->simple)
  ------------------
  |  Branch (3105:9): [True: 586, False: 13]
  ------------------
 3106|    586|        block->keyframe = header_flags & 0x80;
 3107|    599|    block->timecode = time * mkv_d->tc_scale + mkv_d->cluster_tc;
 3108|  1.11k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (3108:21): [True: 972, False: 143]
  ------------------
 3109|    972|        if (mkv_d->tracks[i]->tnum == num) {
  ------------------
  |  Branch (3109:13): [True: 456, False: 516]
  ------------------
 3110|    456|            block->track = mkv_d->tracks[i];
 3111|    456|            break;
 3112|    456|        }
 3113|    972|    }
 3114|    599|    if (!block->track) {
  ------------------
  |  Branch (3114:9): [True: 143, False: 456]
  ------------------
 3115|    143|        res = 0;
 3116|    143|        goto exit;
 3117|    143|    }
 3118|       |
 3119|    456|    if (stream_tell(s) != endpos)
  ------------------
  |  Branch (3119:9): [True: 0, False: 456]
  ------------------
 3120|      0|        goto exit;
 3121|       |
 3122|    456|    res = 1;
 3123|  1.60k|exit:
 3124|  1.60k|    if (res <= 0)
  ------------------
  |  Branch (3124:9): [True: 1.14k, False: 456]
  ------------------
 3125|  1.14k|        free_block(block);
 3126|  1.60k|    stream_seek_skip(s, endpos);
 3127|  1.60k|    return res;
 3128|    456|}
demux_mkv.c:demux_mkv_read_block_lacing:
 2644|  1.30k|{
 2645|  1.30k|    int laces;
 2646|  1.30k|    uint32_t lace_size[MAX_NUM_LACES];
 2647|       |
 2648|       |
 2649|  1.30k|    if (type == 0) {           /* no lacing */
  ------------------
  |  Branch (2649:9): [True: 16, False: 1.28k]
  ------------------
 2650|     16|        laces = 1;
 2651|     16|        lace_size[0] = endpos - stream_tell(s);
 2652|  1.28k|    } else {
 2653|  1.28k|        laces = stream_read_char(s);
 2654|  1.28k|        if (laces < 0 || stream_tell(s) > endpos)
  ------------------
  |  Branch (2654:13): [True: 0, False: 1.28k]
  |  Branch (2654:26): [True: 0, False: 1.28k]
  ------------------
 2655|      0|            goto error;
 2656|  1.28k|        laces += 1;
 2657|       |
 2658|  1.28k|        switch (type) {
 2659|    714|        case 1: {              /* xiph lacing */
  ------------------
  |  Branch (2659:9): [True: 714, False: 575]
  ------------------
 2660|    714|            uint32_t total = 0;
 2661|  8.84k|            for (int i = 0; i < laces - 1; i++) {
  ------------------
  |  Branch (2661:29): [True: 8.20k, False: 636]
  ------------------
 2662|  8.20k|                lace_size[i] = 0;
 2663|  8.20k|                uint8_t t;
 2664|  8.56k|                do {
 2665|  8.56k|                    t = stream_read_char(s);
 2666|  8.56k|                    if (s->eof || stream_tell(s) >= endpos)
  ------------------
  |  Branch (2666:25): [True: 2, False: 8.56k]
  |  Branch (2666:35): [True: 76, False: 8.49k]
  ------------------
 2667|     78|                        goto error;
 2668|  8.49k|                    lace_size[i] += t;
 2669|  8.49k|                } while (t == 0xFF);
  ------------------
  |  Branch (2669:26): [True: 360, False: 8.13k]
  ------------------
 2670|  8.13k|                total += lace_size[i];
 2671|  8.13k|            }
 2672|    636|            uint32_t rest_length = endpos - stream_tell(s);
 2673|    636|            lace_size[laces - 1] = rest_length - total;
 2674|    636|            break;
 2675|    714|        }
 2676|       |
 2677|    138|        case 2: {              /* fixed-size lacing */
  ------------------
  |  Branch (2677:9): [True: 138, False: 1.15k]
  ------------------
 2678|    138|            uint32_t full_length = endpos - stream_tell(s);
 2679|  21.4k|            for (int i = 0; i < laces; i++)
  ------------------
  |  Branch (2679:29): [True: 21.3k, False: 138]
  ------------------
 2680|  21.3k|                lace_size[i] = full_length / laces;
 2681|    138|            break;
 2682|    714|        }
 2683|       |
 2684|    437|        case 3: {              /* EBML lacing */
  ------------------
  |  Branch (2684:9): [True: 437, False: 852]
  ------------------
 2685|    437|            uint64_t num = ebml_read_length(s);
 2686|    437|            if (num == EBML_UINT_INVALID || stream_tell(s) >= endpos)
  ------------------
  |  |   85|    874|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (2686:17): [True: 76, False: 361]
  |  Branch (2686:45): [True: 1, False: 360]
  ------------------
 2687|     77|                goto error;
 2688|       |
 2689|    360|            uint32_t total = lace_size[0] = num;
 2690|  9.45k|            for (int i = 1; i < laces - 1; i++) {
  ------------------
  |  Branch (2690:29): [True: 9.24k, False: 211]
  ------------------
 2691|  9.24k|                int64_t snum = ebml_read_signed_length(s);
 2692|  9.24k|                if (snum == EBML_INT_INVALID || stream_tell(s) >= endpos)
  ------------------
  |  |   86|  18.4k|#define EBML_INT_INVALID    INT64_MAX
  ------------------
  |  Branch (2692:21): [True: 138, False: 9.10k]
  |  Branch (2692:49): [True: 11, False: 9.09k]
  ------------------
 2693|    149|                    goto error;
 2694|  9.09k|                lace_size[i] = lace_size[i - 1] + snum;
 2695|  9.09k|                total += lace_size[i];
 2696|  9.09k|            }
 2697|    211|            uint32_t rest_length = endpos - stream_tell(s);
 2698|    211|            lace_size[laces - 1] = rest_length - total;
 2699|    211|            break;
 2700|    360|        }
 2701|       |
 2702|      0|        default:
  ------------------
  |  Branch (2702:9): [True: 0, False: 1.28k]
  ------------------
 2703|      0|            goto error;
 2704|  1.28k|        }
 2705|  1.28k|    }
 2706|       |
 2707|  23.6k|    for (int i = 0; i < laces; i++) {
  ------------------
  |  Branch (2707:21): [True: 22.9k, False: 694]
  ------------------
 2708|  22.9k|        uint32_t size = lace_size[i];
 2709|  22.9k|        if (stream_tell(s) + size > endpos || size > (1 << 30))
  ------------------
  |  Branch (2709:13): [True: 203, False: 22.7k]
  |  Branch (2709:47): [True: 0, False: 22.7k]
  ------------------
 2710|    203|            goto error;
 2711|  22.7k|        int pad = MPMAX(AV_INPUT_BUFFER_PADDING_SIZE, AV_LZO_INPUT_PADDING);
  ------------------
  |  |   44|  22.7k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 22.7k, Folded]
  |  |  ------------------
  ------------------
 2712|  22.7k|        AVBufferRef *buf = av_buffer_alloc(size + pad);
 2713|  22.7k|        if (!buf)
  ------------------
  |  Branch (2713:13): [True: 0, False: 22.7k]
  ------------------
 2714|      0|            goto error;
 2715|  22.7k|        buf->size = size;
 2716|  22.7k|        if (stream_read(s, buf->data, buf->size) != buf->size) {
  ------------------
  |  Branch (2716:13): [True: 104, False: 22.6k]
  ------------------
 2717|    104|            av_buffer_unref(&buf);
 2718|    104|            goto error;
 2719|    104|        }
 2720|  22.6k|        memset(buf->data + buf->size, 0, pad);
 2721|  22.6k|        block->laces[block->num_laces++] = buf;
 2722|  22.6k|    }
 2723|       |
 2724|    694|    if (stream_tell(s) != endpos)
  ------------------
  |  Branch (2724:9): [True: 95, False: 599]
  ------------------
 2725|     95|        goto error;
 2726|       |
 2727|    599|    return 0;
 2728|       |
 2729|    706| error:
 2730|    706|    return 1;
 2731|    694|}
demux_mkv.c:index_block:
 3059|    456|{
 3060|    456|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 3061|    456|    if (block->keyframe) {
  ------------------
  |  Branch (3061:9): [True: 32, False: 424]
  ------------------
 3062|     32|        add_block_position(demuxer, block->track, mkv_d->cluster_start,
 3063|     32|                           block->timecode / mkv_d->tc_scale,
 3064|     32|                           block->duration / mkv_d->tc_scale);
 3065|     32|    }
 3066|    456|}
demux_mkv.c:add_block_position:
 1070|     32|{
 1071|     32|    mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
 1072|       |
 1073|     32|    if (mkv_d->index_complete || !track)
  ------------------
  |  Branch (1073:9): [True: 0, False: 32]
  |  Branch (1073:34): [True: 0, False: 32]
  ------------------
 1074|      0|        return;
 1075|       |
 1076|     32|    mkv_d->index_has_durations = true;
 1077|       |
 1078|     32|    if (track->last_index_entry != (size_t)-1) {
  ------------------
  |  Branch (1078:9): [True: 21, False: 11]
  ------------------
 1079|     21|        mkv_index_t *index = &mkv_d->indexes[track->last_index_entry];
 1080|       |        // Never add blocks which are already covered by the index.
 1081|     21|        if (index->timecode >= timecode)
  ------------------
  |  Branch (1081:13): [True: 20, False: 1]
  ------------------
 1082|     20|            return;
 1083|     21|    }
 1084|     12|    cue_index_add(demuxer, track->tnum, filepos, timecode, duration);
 1085|     12|    track->last_index_entry = mkv_d->num_indexes - 1;
 1086|     12|}
demux_mkv.c:mkv_seek_reset:
 2837|  40.0k|{
 2838|  40.0k|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2839|       |
 2840|  40.5k|    for (int i = 0; i < mkv_d->num_tracks; i++) {
  ------------------
  |  Branch (2840:21): [True: 579, False: 40.0k]
  ------------------
 2841|    579|        mkv_track_t *track = mkv_d->tracks[i];
 2842|    579|        if (track->av_parser)
  ------------------
  |  Branch (2842:13): [True: 0, False: 579]
  ------------------
 2843|      0|            av_parser_close(track->av_parser);
 2844|    579|        track->av_parser = NULL;
 2845|    579|        avcodec_free_context(&track->av_parser_codec);
 2846|    579|        mp_dovi_split_reset(track->dovi_split);
 2847|    579|    }
 2848|       |
 2849|  40.4k|    for (int n = 0; n < mkv_d->num_blocks; n++)
  ------------------
  |  Branch (2849:21): [True: 456, False: 40.0k]
  ------------------
 2850|    456|        free_block(&mkv_d->blocks[n]);
 2851|  40.0k|    mkv_d->num_blocks = 0;
 2852|       |
 2853|  40.0k|    for (int n = 0; n < mkv_d->num_packets; n++)
  ------------------
  |  Branch (2853:21): [True: 0, False: 40.0k]
  ------------------
 2854|      0|        talloc_free(mkv_d->packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2855|  40.0k|    mkv_d->num_packets = 0;
 2856|       |
 2857|       |    mkv_d->skip_to_timecode = INT64_MIN;
 2858|  40.0k|}
demux_mkv.c:probe_x264_garbage:
 2379|    545|{
 2380|    545|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2381|       |
 2382|  1.12k|    for (int n = 0; n < mkv_d->num_tracks; n++) {
  ------------------
  |  Branch (2382:21): [True: 579, False: 545]
  ------------------
 2383|    579|        mkv_track_t *track = mkv_d->tracks[n];
 2384|    579|        struct sh_stream *sh = track->stream;
 2385|       |
 2386|    579|        if (!sh || sh->type != STREAM_VIDEO)
  ------------------
  |  Branch (2386:13): [True: 28, False: 551]
  |  Branch (2386:20): [True: 292, False: 259]
  ------------------
 2387|    320|            continue;
 2388|       |
 2389|    259|        if (sh->codec->codec && strcmp(sh->codec->codec, "h264") != 0)
  ------------------
  |  Branch (2389:13): [True: 259, False: 0]
  |  Branch (2389:33): [True: 259, False: 0]
  ------------------
 2390|    259|            continue;
 2391|       |
 2392|      0|        struct block_info *block = NULL;
 2393|       |
 2394|       |        // Find first block for this track.
 2395|       |        // Restrict reading number of total packets. (Arbitrary to avoid bloat.)
 2396|      0|        for (int i = 0; i < 100; i++) {
  ------------------
  |  Branch (2396:25): [True: 0, False: 0]
  ------------------
 2397|      0|            if (i >= mkv_d->num_blocks && read_next_block_into_queue(demuxer) < 1)
  ------------------
  |  Branch (2397:17): [True: 0, False: 0]
  |  Branch (2397:43): [True: 0, False: 0]
  ------------------
 2398|      0|                break;
 2399|      0|            if (mkv_d->blocks[i].track == track) {
  ------------------
  |  Branch (2399:17): [True: 0, False: 0]
  ------------------
 2400|      0|                block = &mkv_d->blocks[i];
 2401|      0|                break;
 2402|      0|            }
 2403|      0|        }
 2404|       |
 2405|      0|        if (!block || block->num_laces < 1)
  ------------------
  |  Branch (2405:13): [True: 0, False: 0]
  |  Branch (2405:23): [True: 0, False: 0]
  ------------------
 2406|      0|            continue;
 2407|       |
 2408|      0|        bstr sblock = {block->laces[0]->data, block->laces[0]->size};
 2409|      0|        bstr nblock = demux_mkv_decode(demuxer->log, track, sblock, 1);
 2410|      0|        if (!nblock.len)
  ------------------
  |  Branch (2410:13): [True: 0, False: 0]
  ------------------
 2411|      0|            continue;
 2412|       |
 2413|      0|        sh->codec->first_packet = new_demux_packet_from(demuxer->packet_pool,
 2414|      0|                                                        nblock.start, nblock.len);
 2415|      0|        talloc_steal(mkv_d, sh->codec->first_packet);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 2416|       |
 2417|      0|        if (nblock.start != sblock.start)
  ------------------
  |  Branch (2417:13): [True: 0, False: 0]
  ------------------
 2418|      0|            talloc_free(nblock.start);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 2419|      0|    }
 2420|    545|}
demux_mkv.c:probe_if_image:
 2347|    545|{
 2348|    545|    mkv_demuxer_t *mkv_d = demuxer->priv;
 2349|       |
 2350|  1.12k|    for (int n = 0; n < mkv_d->num_tracks; n++) {
  ------------------
  |  Branch (2350:21): [True: 579, False: 545]
  ------------------
 2351|    579|        int video_blocks = 0;
 2352|    579|        mkv_track_t *track = mkv_d->tracks[n];
 2353|    579|        struct sh_stream *sh = track->stream;
 2354|       |
 2355|    579|        if (!sh || sh->type != STREAM_VIDEO || sh->image)
  ------------------
  |  Branch (2355:13): [True: 28, False: 551]
  |  Branch (2355:20): [True: 292, False: 259]
  |  Branch (2355:48): [True: 0, False: 259]
  ------------------
 2356|    320|            continue;
 2357|       |
 2358|    259|        int64_t timecode = -1;
 2359|       |        // Arbitrary restriction on packet reading.
 2360|    736|        for (size_t block = 0; block < 10000; block++) {
  ------------------
  |  Branch (2360:32): [True: 736, False: 0]
  ------------------
 2361|    736|            if (block >= mkv_d->num_blocks && read_next_block_into_queue(demuxer) != 1)
  ------------------
  |  Branch (2361:17): [True: 627, False: 109]
  |  Branch (2361:47): [True: 254, False: 373]
  ------------------
 2362|    254|                break;
 2363|    482|            if (mkv_d->blocks[block].track != track)
  ------------------
  |  Branch (2363:17): [True: 27, False: 455]
  ------------------
 2364|     27|                continue;
 2365|    455|            if (timecode != mkv_d->blocks[block].timecode)
  ------------------
  |  Branch (2365:17): [True: 87, False: 368]
  ------------------
 2366|     87|                ++video_blocks;
 2367|    455|            timecode = mkv_d->blocks[block].timecode;
 2368|    455|            if (video_blocks > 1)
  ------------------
  |  Branch (2368:17): [True: 5, False: 450]
  ------------------
 2369|      5|                break;
 2370|    455|        }
 2371|       |
 2372|       |        // Assume still image
 2373|    259|        if (video_blocks == 1)
  ------------------
  |  Branch (2373:13): [True: 77, False: 182]
  ------------------
 2374|     77|            sh->image = true;
 2375|    259|    }
 2376|    545|}
demux_mkv.c:mkv_free:
 3790|  40.0k|{
 3791|  40.0k|    struct mkv_demuxer *mkv_d = demuxer->priv;
 3792|  40.0k|    if (!mkv_d)
  ------------------
  |  Branch (3792:9): [True: 0, False: 40.0k]
  ------------------
 3793|      0|        return;
 3794|  40.0k|    mkv_seek_reset(demuxer);
 3795|  40.5k|    for (int i = 0; i < mkv_d->num_tracks; i++)
  ------------------
  |  Branch (3795:21): [True: 579, False: 40.0k]
  ------------------
 3796|    579|        demux_mkv_free_trackentry(mkv_d->tracks[i]);
 3797|  40.0k|}
demux_mkv.c:demux_mkv_free_trackentry:
  888|    579|{
  889|    579|    talloc_free(track->parser_tmp);
  ------------------
  |  |   47|    579|#define talloc_free                     ta_free
  ------------------
  890|    579|    av_freep(&track->dovi_config);
  891|    579|    TA_FREEP(&track->dovi_split);
  ------------------
  |  |   81|    579|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|    579|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 579]
  |  |  ------------------
  ------------------
  892|    579|    talloc_free(track);
  ------------------
  |  |   47|    579|#define talloc_free                     ta_free
  ------------------
  893|    579|}

build_ordered_chapter_timeline:
  515|    545|{
  516|    545|    struct demuxer *demuxer = tl->demuxer;
  517|       |
  518|    545|    if (!demuxer->matroska_data.ordered_chapters)
  ------------------
  |  Branch (518:9): [True: 545, False: 0]
  ------------------
  519|    545|        return;
  520|       |
  521|      0|    struct tl_ctx *ctx = talloc_ptrtype(tl, ctx);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  522|      0|    *ctx = (struct tl_ctx){
  523|      0|        .log = tl->log,
  524|      0|        .global = tl->global,
  525|      0|        .tl = tl,
  526|      0|        .demuxer = demuxer,
  527|      0|        .opts = mp_get_config_group(ctx, tl->global, &mp_opt_root),
  528|      0|    };
  529|       |
  530|      0|    if (!ctx->opts->ordered_chapters || !demuxer->access_references) {
  ------------------
  |  Branch (530:9): [True: 0, False: 0]
  |  Branch (530:41): [True: 0, False: 0]
  ------------------
  531|      0|        MP_INFO(demuxer, "File uses ordered chapters, but "
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  532|      0|                "you have disabled support for them. Ignoring.\n");
  533|      0|        talloc_free(ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  534|      0|        return;
  535|      0|    }
  536|       |
  537|      0|    MP_INFO(ctx, "File uses ordered chapters, will build edit timeline.\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__)
  |  |  ------------------
  ------------------
  538|       |
  539|      0|    struct matroska_data *m = &demuxer->matroska_data;
  540|       |
  541|       |    // +1 because sources/uid_map[0] is original file even if all chapters
  542|       |    // actually use other sources and need separate entries
  543|      0|    ctx->sources = talloc_zero_array(tl, struct demuxer *,
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|      0|                                     m->num_ordered_chapters + 1);
  545|      0|    ctx->sources[0] = demuxer;
  546|      0|    ctx->num_sources = 1;
  547|       |
  548|      0|    ctx->uids = talloc_zero_array(NULL, struct matroska_segment_uid,
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  549|      0|                                  m->num_ordered_chapters + 1);
  550|      0|    ctx->uids[0] = m->uid;
  551|      0|    ctx->uids[0].edition = 0;
  552|       |
  553|      0|    for (int i = 0; i < m->num_ordered_chapters; i++) {
  ------------------
  |  Branch (553:21): [True: 0, False: 0]
  ------------------
  554|      0|        struct matroska_chapter *c = m->ordered_chapters + i;
  555|       |        /* If there isn't a segment uid, we are the source. If the segment uid
  556|       |         * is our segment uid and the edition matches. We can't accept the
  557|       |         * "don't care" edition value of 0 since the user may have requested a
  558|       |         * non-default edition. */
  559|      0|        if (!c->has_segment_uid || demux_matroska_uid_cmp(&c->uid, &m->uid))
  ------------------
  |  Branch (559:13): [True: 0, False: 0]
  |  Branch (559:36): [True: 0, False: 0]
  ------------------
  560|      0|            continue;
  561|       |
  562|      0|        if (has_source_request(ctx, &c->uid))
  ------------------
  |  Branch (562:13): [True: 0, False: 0]
  ------------------
  563|      0|            continue;
  564|       |
  565|      0|        ctx->uids[ctx->num_sources] = c->uid;
  566|      0|        ctx->sources[ctx->num_sources] = NULL;
  567|      0|        ctx->num_sources++;
  568|      0|    }
  569|       |
  570|      0|    find_ordered_chapter_sources(ctx);
  571|       |
  572|      0|    talloc_free(ctx->uids);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  573|      0|    ctx->uids = NULL;
  574|       |
  575|      0|    struct demux_chapter *chapters =
  576|      0|        talloc_zero_array(tl, struct demux_chapter, m->num_ordered_chapters);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|       |
  578|      0|    ctx->timeline = talloc_array_ptrtype(tl, ctx->timeline, 0);
  ------------------
  |  |   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)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|      0|    ctx->num_chapters = m->num_ordered_chapters;
  580|       |
  581|      0|    struct inner_timeline_info info = {
  582|      0|        .skip = 0,
  583|      0|        .limit = 0
  584|      0|    };
  585|      0|    build_timeline_loop(ctx, chapters, &info, 0);
  586|       |
  587|       |    // Fuck everything: filter out all "unset" chapters.
  588|      0|    for (int n = m->num_ordered_chapters - 1; n >= 0; n--) {
  ------------------
  |  Branch (588:47): [True: 0, False: 0]
  ------------------
  589|      0|        if (!chapters[n].metadata)
  ------------------
  |  Branch (589:13): [True: 0, False: 0]
  ------------------
  590|      0|            MP_TARRAY_REMOVE_AT(chapters, m->num_ordered_chapters, 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 (590:13): [True: 0, False: 0]
  ------------------
  591|      0|    }
  592|       |
  593|      0|    if (!ctx->num_parts) {
  ------------------
  |  Branch (593:9): [True: 0, False: 0]
  ------------------
  594|       |        // None of  the parts come from the file itself???
  595|       |        // Broken file, but we need at least 1 valid timeline part - add a dummy.
  596|      0|        MP_WARN(ctx, "Ordered chapters file with no parts?\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__)
  |  |  ------------------
  ------------------
  597|      0|        struct timeline_part new = {
  598|      0|            .source = demuxer,
  599|      0|        };
  600|      0|        MP_TARRAY_APPEND(NULL, ctx->timeline, ctx->num_parts, new);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  601|      0|    }
  602|       |
  603|      0|    for (int n = 0; n < ctx->num_parts; n++) {
  ------------------
  |  Branch (603:21): [True: 0, False: 0]
  ------------------
  604|      0|        ctx->timeline[n].end = n == ctx->num_parts - 1
  ------------------
  |  Branch (604:32): [True: 0, False: 0]
  ------------------
  605|      0|            ? ctx->start_time / 1e9
  606|      0|            : ctx->timeline[n + 1].start;
  607|      0|    };
  608|       |
  609|       |    /* Ignore anything less than a millisecond when reporting missing time. If
  610|       |     * users really notice less than a millisecond missing, maybe this can be
  611|       |     * revisited. */
  612|      0|    if (ctx->missing_time >= 1e6) {
  ------------------
  |  Branch (612:9): [True: 0, False: 0]
  ------------------
  613|      0|        MP_ERR(ctx, "There are %.3f seconds missing from the timeline!\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__)
  |  |  ------------------
  ------------------
  614|      0|               ctx->missing_time / 1e9);
  615|      0|    }
  616|       |
  617|       |    // With Matroska, the "master" file usually dictates track layout etc.,
  618|       |    // except maybe with playlist-like files.
  619|      0|    struct demuxer *track_layout = ctx->timeline[0].source;
  620|      0|    for (int n = 0; n < ctx->num_parts; n++) {
  ------------------
  |  Branch (620:21): [True: 0, False: 0]
  ------------------
  621|      0|        if (ctx->timeline[n].source == ctx->demuxer) {
  ------------------
  |  Branch (621:13): [True: 0, False: 0]
  ------------------
  622|      0|            track_layout = ctx->demuxer;
  623|      0|            break;
  624|      0|        }
  625|      0|    }
  626|       |
  627|      0|    check_track_compatibility(ctx, track_layout);
  628|       |
  629|      0|    tl->sources = ctx->sources;
  630|      0|    tl->num_sources = ctx->num_sources;
  631|       |
  632|      0|    struct timeline_par *par = talloc_ptrtype(tl, par);
  ------------------
  |  |   34|      0|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|      0|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|      0|    *par = (struct timeline_par){
  634|      0|        .parts = ctx->timeline,
  635|      0|        .num_parts = ctx->num_parts,
  636|      0|        .track_layout = track_layout,
  637|      0|    };
  638|      0|    MP_TARRAY_APPEND(tl, tl->pars, tl->num_pars, par);
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  639|      0|    tl->chapters = chapters;
  640|      0|    tl->num_chapters = m->num_ordered_chapters;
  641|      0|    tl->meta = track_layout;
  642|      0|    tl->format = "mkv_oc";
  643|      0|}

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

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

demux_playlist.c:open_file:
  646|  55.0k|{
  647|  55.0k|    if (!demuxer->access_references)
  ------------------
  |  Branch (647:9): [True: 0, False: 55.0k]
  ------------------
  648|      0|        return -1;
  649|       |
  650|  55.0k|    bool force = check < DEMUX_CHECK_UNSAFE || check == DEMUX_CHECK_REQUEST;
  ------------------
  |  Branch (650:18): [True: 0, False: 55.0k]
  |  Branch (650:48): [True: 0, False: 55.0k]
  ------------------
  651|       |
  652|  55.0k|    struct pl_parser *p = talloc_zero(NULL, struct pl_parser);
  ------------------
  |  |   27|  55.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  55.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  55.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|  55.0k|    p->global = demuxer->global;
  654|  55.0k|    p->log = demuxer->log;
  655|  55.0k|    p->pl = talloc_zero(p, struct playlist);
  ------------------
  |  |   27|  55.0k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  55.0k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  55.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|  55.0k|    p->real_stream = demuxer->stream;
  657|       |
  658|  55.0k|    struct demux_opts *opts = mp_get_config_group(p, p->global, &demux_conf);
  659|  55.0k|    p->codepage = opts->meta_cp;
  660|       |
  661|  55.0k|    char probe[PROBE_SIZE];
  662|  55.0k|    int probe_len = stream_read_peek(p->real_stream, probe, sizeof(probe));
  663|  55.0k|    p->s = stream_memory_open(demuxer->global, probe, probe_len);
  664|  55.0k|    p->s->mime_type = demuxer->stream->mime_type;
  665|  55.0k|    p->utf16 = stream_skip_bom(p->s);
  666|  55.0k|    p->force = force;
  667|  55.0k|    p->check_level = check;
  668|  55.0k|    p->probing = true;
  669|  55.0k|    p->autocreate_playlist = demuxer->params->allow_playlist_create ? opts->autocreate_playlist : 0;
  ------------------
  |  Branch (669:30): [True: 0, False: 55.0k]
  ------------------
  670|  55.0k|    p->directory_filter = opts->directory_filter;
  671|  55.0k|    p->mp_opts = mp_get_config_group(demuxer, demuxer->global, &mp_opt_root);
  672|  55.0k|    p->opts = mp_get_config_group(demuxer, demuxer->global, &demux_playlist_conf);
  673|       |
  674|  55.0k|    const struct pl_format *fmts = playlist_formats;
  675|  55.0k|    if (demuxer->desc == &demuxer_desc_directory)
  ------------------
  |  Branch (675:9): [True: 40.0k, False: 15.0k]
  ------------------
  676|  40.0k|        fmts = dir_formats;
  677|       |
  678|  55.0k|    const struct pl_format *fmt = probe_pl(p, fmts);
  679|  55.0k|    free_stream(p->s);
  680|  55.0k|    playlist_clear(p->pl);
  681|  55.0k|    if (!fmt) {
  ------------------
  |  Branch (681:9): [True: 55.0k, False: 0]
  ------------------
  682|  55.0k|        talloc_free(p);
  ------------------
  |  |   47|  55.0k|#define talloc_free                     ta_free
  ------------------
  683|  55.0k|        return -1;
  684|  55.0k|    }
  685|       |
  686|      0|    p->probing = false;
  687|      0|    p->error = false;
  688|      0|    p->s = demuxer->stream;
  689|      0|    p->utf16 = stream_skip_bom(p->s);
  690|      0|    bool ok = fmt->parse(p) >= 0 && !p->error;
  ------------------
  |  Branch (690:15): [True: 0, False: 0]
  |  Branch (690:37): [True: 0, False: 0]
  ------------------
  691|      0|    playlist_set_stream_flags(p->pl, demuxer->stream_origin);
  692|      0|    demuxer->playlist = talloc_steal(demuxer, p->pl);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  693|      0|    demuxer->filetype = p->format ? p->format : fmt->name;
  ------------------
  |  Branch (693:25): [True: 0, False: 0]
  ------------------
  694|      0|    demuxer->fully_read = true;
  695|      0|    talloc_free(p);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  696|      0|    if (ok)
  ------------------
  |  Branch (696:9): [True: 0, False: 0]
  ------------------
  697|      0|        demux_close_stream(demuxer);
  698|      0|    return ok ? 0 : -1;
  ------------------
  |  Branch (698:12): [True: 0, False: 0]
  ------------------
  699|  55.0k|}
demux_playlist.c:parse_m3u:
  248|  30.0k|{
  249|  30.0k|    bstr line = pl_get_line(p);
  250|  30.0k|    if (p->probing && !bstr_equals0(line, "#EXTM3U")) {
  ------------------
  |  Branch (250:9): [True: 30.0k, False: 0]
  |  Branch (250:23): [True: 30.0k, False: 0]
  ------------------
  251|       |        // Last resort: if the file extension is m3u, it might be headerless.
  252|  30.0k|        if (p->check_level == DEMUX_CHECK_UNSAFE) {
  ------------------
  |  Branch (252:13): [True: 15.0k, False: 15.0k]
  ------------------
  253|  15.0k|            bstr ext = mp_get_ext(bstr0(p->real_stream->url));
  254|  15.0k|            char probe[PROBE_SIZE];
  255|  15.0k|            int len = stream_read_peek(p->real_stream, probe, sizeof(probe));
  256|  15.0k|            bstr data = {probe, len};
  257|  15.0k|            if (ext.len && data.len >= 2 && maybe_text(data)) {
  ------------------
  |  Branch (257:17): [True: 0, False: 15.0k]
  |  Branch (257:28): [True: 0, False: 0]
  |  Branch (257:45): [True: 0, False: 0]
  ------------------
  258|      0|                const char *exts[] = {"m3u", "m3u8", "strm", NULL};
  259|      0|                for (int n = 0; exts[n]; n++) {
  ------------------
  |  Branch (259:33): [True: 0, False: 0]
  ------------------
  260|      0|                    if (bstrcasecmp(ext, bstr0(exts[n])) == 0)
  ------------------
  |  Branch (260:25): [True: 0, False: 0]
  ------------------
  261|      0|                        goto ok;
  262|      0|                }
  263|      0|            }
  264|  15.0k|        }
  265|  30.0k|        pl_free_line(p, line);
  266|  30.0k|        return -1;
  267|  30.0k|    }
  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|   111k|{
  193|   111k|    bstr line = bstr_strip(bstr0(pl_get_line0(p)));
  194|   111k|    const char *charset = mp_charset_guess(p, p->log, line, p->codepage, 0);
  195|   111k|    if (charset && !mp_charset_is_utf8(charset)) {
  ------------------
  |  Branch (195:9): [True: 111k, False: 0]
  |  Branch (195:20): [True: 24.3k, False: 86.9k]
  ------------------
  196|  24.3k|        bstr utf8 = mp_iconv_to_utf8(p->log, line, charset, 0);
  197|  24.3k|        if (utf8.start && utf8.start != line.start) {
  ------------------
  |  Branch (197:13): [True: 24.3k, False: 0]
  |  Branch (197:27): [True: 24.3k, False: 0]
  ------------------
  198|  24.3k|            line = utf8;
  199|       |            p->line_allocated = true;
  200|  24.3k|        }
  201|  24.3k|    }
  202|   111k|    return line;
  203|   111k|}
demux_playlist.c:pl_get_line0:
  179|   111k|{
  180|   111k|    char *res = read_line(p->s, p->buffer, sizeof(p->buffer), p->utf16);
  181|   111k|    if (res) {
  ------------------
  |  Branch (181:9): [True: 89.1k, False: 22.0k]
  ------------------
  182|  89.1k|        int len = strlen(res);
  183|  89.1k|        if (len > 0 && res[len - 1] == '\n')
  ------------------
  |  Branch (183:13): [True: 89.1k, False: 0]
  |  Branch (183:24): [True: 69.6k, False: 19.5k]
  ------------------
  184|  69.6k|            res[len - 1] = '\0';
  185|  89.1k|    } else {
  186|  22.0k|        p->error |= !p->s->eof;
  187|  22.0k|    }
  188|   111k|    return res;
  189|   111k|}
demux_playlist.c:read_line:
  157|   111k|{
  158|   111k|    if (max < 1)
  ------------------
  |  Branch (158:9): [True: 0, False: 111k]
  ------------------
  159|      0|        return NULL;
  160|   111k|    int read = 0;
  161|   135k|    while (1) {
  ------------------
  |  Branch (161:12): [True: 135k, Folded]
  ------------------
  162|       |        // Reserve 1 byte of ptr for terminating \0.
  163|   135k|        int l = read_characters(s, &mem[read], max - read - 1, utf16);
  164|   135k|        if (l < 0 || memchr(&mem[read], '\0', l)) {
  ------------------
  |  Branch (164:13): [True: 492, False: 134k]
  |  Branch (164:22): [True: 21.4k, False: 113k]
  ------------------
  165|  21.9k|            MP_WARN(s, "error reading line\n");
  ------------------
  |  |   90|  21.9k|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  21.9k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  166|  21.9k|            return NULL;
  167|  21.9k|        }
  168|   113k|        read += l;
  169|   113k|        if (l == 0 || (read > 0 && mem[read - 1] == '\n'))
  ------------------
  |  Branch (169:13): [True: 19.6k, False: 93.7k]
  |  Branch (169:24): [True: 93.7k, False: 0]
  |  Branch (169:36): [True: 69.6k, False: 24.0k]
  ------------------
  170|  89.2k|            break;
  171|   113k|    }
  172|  89.2k|    mem[read] = '\0';
  173|  89.2k|    if (!stream_read_peek(s, &(char){0}, 1) && read == 0) // legitimate EOF
  ------------------
  |  Branch (173:9): [True: 20.0k, False: 69.2k]
  |  Branch (173:48): [True: 104, False: 19.9k]
  ------------------
  174|    104|        return NULL;
  175|  89.1k|    return mem;
  176|  89.2k|}
demux_playlist.c:read_characters:
  122|   135k|{
  123|   135k|    if (utf16 == 1 || utf16 == 2) {
  ------------------
  |  Branch (123:9): [True: 1.30k, False: 134k]
  |  Branch (123:23): [True: 1.27k, False: 132k]
  ------------------
  124|  2.57k|        uint8_t *cur = dst;
  125|  32.8k|        while (1) {
  ------------------
  |  Branch (125:16): [True: 32.8k, Folded]
  ------------------
  126|  32.8k|            if ((cur - dst) + 8 >= dstsize) // PUT_UTF8 writes max. 8 bytes
  ------------------
  |  Branch (126:17): [True: 0, False: 32.8k]
  ------------------
  127|      0|                return -1; // line too long
  128|  32.8k|            uint32_t c;
  129|  32.8k|            uint8_t tmp;
  130|  32.8k|            GET_UTF16(c, stream_read_word_endian(s, utf16 == 2), return -1;)
  ------------------
  |  Branch (130:13): [True: 388, False: 252]
  |  Branch (130:13): [True: 104, False: 148]
  |  Branch (130:13): [True: 640, False: 32.2k]
  ------------------
  131|  32.3k|            if (s->eof)
  ------------------
  |  Branch (131:17): [True: 1.70k, False: 30.6k]
  ------------------
  132|  1.70k|                break; // legitimate EOF; ignore the case of partial reads
  133|  32.3k|            PUT_UTF8(c, tmp, *cur++ = tmp;)
  ------------------
  |  Branch (133:13): [True: 47.3k, False: 24.2k]
  |  Branch (133:13): [True: 6.44k, False: 24.2k]
  ------------------
  134|  30.6k|            if (c == '\n')
  ------------------
  |  Branch (134:17): [True: 380, False: 30.2k]
  ------------------
  135|    380|                break;
  136|  30.6k|        }
  137|  2.08k|        return cur - dst;
  138|   132k|    } else {
  139|   132k|        uint8_t buf[1024];
  140|   132k|        int buf_len = stream_read_peek(s, buf, sizeof(buf));
  141|   132k|        uint8_t *end = memchr(buf, '\n', buf_len);
  142|   132k|        int len = end ? end - buf + 1 : buf_len;
  ------------------
  |  Branch (142:19): [True: 78.5k, False: 54.1k]
  ------------------
  143|   132k|        if (len > dstsize)
  ------------------
  |  Branch (143:13): [True: 0, False: 132k]
  ------------------
  144|      0|            return -1; // line too long
  145|   132k|        memcpy(dst, buf, len);
  146|   132k|        stream_seek_skip(s, stream_tell(s) + len);
  147|   132k|        return len;
  148|   132k|    }
  149|   135k|}
demux_playlist.c:stream_read_word_endian:
  111|  33.5k|{
  112|  33.5k|    unsigned int y = stream_read_char(s);
  113|  33.5k|    y = (y << 8) | stream_read_char(s);
  114|  33.5k|    if (!big_endian)
  ------------------
  |  Branch (114:9): [True: 16.7k, False: 16.7k]
  ------------------
  115|  16.7k|        y = ((y >> 8) & 0xFF) | (y << 8);
  116|  33.5k|    return y;
  117|  33.5k|}
demux_playlist.c:pl_free_line:
  207|  75.0k|{
  208|  75.0k|    if (p->line_allocated) {
  ------------------
  |  Branch (208:9): [True: 24.3k, False: 50.7k]
  ------------------
  209|  24.3k|        talloc_free(line.start);
  ------------------
  |  |   47|  24.3k|#define talloc_free                     ta_free
  ------------------
  210|       |        p->line_allocated = false;
  211|  24.3k|    }
  212|  75.0k|}
demux_playlist.c:pl_eof:
  233|  81.3k|{
  234|  81.3k|    return p->error || p->s->eof;
  ------------------
  |  Branch (234:12): [True: 14.7k, False: 66.6k]
  |  Branch (234:24): [True: 436, False: 66.2k]
  ------------------
  235|  81.3k|}
demux_playlist.c:parse_ref_init:
  303|  15.0k|{
  304|  15.0k|    bstr line = pl_get_line(p);
  305|  15.0k|    if (!bstr_equals0(line, "[Reference]")) {
  ------------------
  |  Branch (305:9): [True: 15.0k, False: 0]
  ------------------
  306|  15.0k|        pl_free_line(p, line);
  307|  15.0k|        return -1;
  308|  15.0k|    }
  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|   130k|{
   79|   130k|    if (s->mime_type) {
  ------------------
  |  Branch (79:9): [True: 0, False: 130k]
  ------------------
   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|   130k|    return false;
   86|   130k|}
demux_playlist.c:parse_pls:
  371|  15.0k|{
  372|  15.0k|    return parse_ini_thing(p, "[playlist]", "File");
  373|  15.0k|}
demux_playlist.c:parse_ini_thing:
  341|  30.0k|{
  342|  30.0k|    bstr line = {0};
  343|  96.2k|    while (!line.len && !pl_eof(p))
  ------------------
  |  Branch (343:12): [True: 81.3k, False: 14.8k]
  |  Branch (343:25): [True: 66.2k, False: 15.1k]
  ------------------
  344|  66.2k|        line = pl_get_line(p);
  345|  30.0k|    if (bstrcasecmp0(line, header) != 0) {
  ------------------
  |  Branch (345:9): [True: 30.0k, False: 0]
  ------------------
  346|  30.0k|        pl_free_line(p, line);
  347|  30.0k|        return -1;
  348|  30.0k|    }
  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|  15.0k|{
  377|  15.0k|    return parse_ini_thing(p, "[InternetShortcut]", "URL");
  378|  15.0k|}
demux_playlist.c:parse_txt:
  381|  15.0k|{
  382|  15.0k|    if (!p->force)
  ------------------
  |  Branch (382:9): [True: 15.0k, False: 0]
  ------------------
  383|  15.0k|        return -1;
  384|      0|    if (p->probing)
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|        return 0;
  386|      0|    MP_WARN(p, "Reading plaintext playlist.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  387|      0|    while (!pl_eof(p)) {
  ------------------
  |  Branch (387:12): [True: 0, False: 0]
  ------------------
  388|      0|        bstr line = pl_get_line(p);
  389|      0|        if (line.len == 0)
  ------------------
  |  Branch (389:13): [True: 0, False: 0]
  ------------------
  390|      0|            continue;
  391|      0|        pl_add(p, line);
  392|      0|        pl_free_line(p, line);
  393|      0|    }
  394|      0|    return 0;
  395|      0|}
demux_playlist.c:parse_dir:
  532|  40.0k|{
  533|  40.0k|    int ret = -1;
  534|  40.0k|    struct stream *stream = p->real_stream;
  535|  40.0k|    enum autocreate_mode autocreate = AUTO_NONE;
  536|  40.0k|    p->pl->playlist_dir = NULL;
  537|  40.0k|    if (p->autocreate_playlist && p->real_stream->is_local_fs && p->real_stream->is_regular &&
  ------------------
  |  Branch (537:9): [True: 0, False: 40.0k]
  |  Branch (537:35): [True: 0, False: 0]
  |  Branch (537:66): [True: 0, False: 0]
  ------------------
  538|      0|        !p->real_stream->is_directory) {
  ------------------
  |  Branch (538:9): [True: 0, False: 0]
  ------------------
  539|      0|        bstr ext = mp_get_ext(bstr0(p->real_stream->url));
  540|      0|        switch (p->autocreate_playlist) {
  ------------------
  |  Branch (540:17): [True: 0, False: 0]
  ------------------
  541|      0|        case 1: // filter
  ------------------
  |  Branch (541:9): [True: 0, False: 0]
  ------------------
  542|      0|            autocreate = get_directory_filter(p);
  543|      0|            break;
  544|      0|        case 2: // same
  ------------------
  |  Branch (544:9): [True: 0, False: 0]
  ------------------
  545|      0|            if (bstr_in_list0(ext, p->mp_opts->video_exts)) {
  ------------------
  |  Branch (545:17): [True: 0, False: 0]
  ------------------
  546|      0|                autocreate = AUTO_VIDEO;
  547|      0|            } else if (bstr_in_list0(ext, p->mp_opts->audio_exts)) {
  ------------------
  |  Branch (547:24): [True: 0, False: 0]
  ------------------
  548|      0|                autocreate = AUTO_AUDIO;
  549|      0|            } else if (bstr_in_list0(ext, p->mp_opts->image_exts)) {
  ------------------
  |  Branch (549:24): [True: 0, False: 0]
  ------------------
  550|      0|                autocreate = AUTO_IMAGE;
  551|      0|            } else if (bstr_in_list0(ext, p->mp_opts->archive_exts)) {
  ------------------
  |  Branch (551:24): [True: 0, False: 0]
  ------------------
  552|      0|                autocreate = AUTO_ARCHIVE;
  553|      0|            } else if (bstr_in_list0(ext, p->mp_opts->playlist_exts)) {
  ------------------
  |  Branch (553:24): [True: 0, False: 0]
  ------------------
  554|      0|                autocreate = AUTO_PLAYLIST;
  555|      0|            }
  556|      0|            break;
  557|      0|        }
  558|      0|        int flags = STREAM_READ_FILE_FLAGS_DEFAULT;
  ------------------
  |  |   60|      0|    (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   47|      0|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  |  |  ------------------
  |  |                   (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   41|      0|#define STREAM_READ               0
  |  |  ------------------
  |  |                   (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   54|      0|#define STREAM_LOCAL_FS_ONLY      (1 << 5) // stream_file only, no URLs
  |  |  ------------------
  |  |                   (STREAM_ORIGIN_DIRECT | STREAM_READ | STREAM_LOCAL_FS_ONLY | STREAM_LESS_NOISE)
  |  |  ------------------
  |  |  |  |   55|      0|#define STREAM_LESS_NOISE         (1 << 6) // try to log errors only
  |  |  ------------------
  ------------------
  559|      0|        bstr dir = mp_dirname(p->real_stream->url);
  560|      0|        if (!dir.len)
  ------------------
  |  Branch (560:13): [True: 0, False: 0]
  ------------------
  561|      0|            autocreate = AUTO_NONE;
  562|      0|        if (autocreate != AUTO_NONE) {
  ------------------
  |  Branch (562:13): [True: 0, False: 0]
  ------------------
  563|      0|            stream = stream_create(bstrdup0(p, dir), flags, NULL, p->global);
  564|      0|            p->pl->playlist_dir = bstrdup0(p->pl, dir);
  565|      0|        }
  566|  40.0k|    } else {
  567|  40.0k|        autocreate = get_directory_filter(p);
  568|  40.0k|    }
  569|  40.0k|    if (!stream->is_directory)
  ------------------
  |  Branch (569:9): [True: 40.0k, False: 0]
  ------------------
  570|  40.0k|        goto done;
  571|      0|    if (p->probing) {
  ------------------
  |  Branch (571:9): [True: 0, False: 0]
  ------------------
  572|      0|        ret = 0;
  573|      0|        goto done;
  574|      0|    }
  575|       |
  576|      0|    char *path = mp_file_get_path(p, bstr0(stream->url));
  577|      0|    if (!path)
  ------------------
  |  Branch (577:9): [True: 0, False: 0]
  ------------------
  578|      0|        goto done;
  579|       |
  580|      0|    if (autocreate == AUTO_NONE)
  ------------------
  |  Branch (580:9): [True: 0, False: 0]
  ------------------
  581|      0|        goto done;
  582|       |
  583|      0|    struct stat dir_stack[MAX_DIR_STACK];
  584|       |
  585|      0|    if (p->opts->dir_mode == DIR_AUTO)
  ------------------
  |  Branch (585:9): [True: 0, False: 0]
  ------------------
  586|      0|        p->opts->dir_mode = p->mp_opts->shuffle ? DIR_RECURSIVE : DIR_LAZY;
  ------------------
  |  Branch (586:29): [True: 0, False: 0]
  ------------------
  587|       |
  588|      0|    scan_dir(p, path, dir_stack, 0, autocreate);
  589|       |
  590|      0|    ret = p->pl->num_entries > 0 ? 0 : -1;
  ------------------
  |  Branch (590:11): [True: 0, False: 0]
  ------------------
  591|       |
  592|  40.0k|done:
  593|  40.0k|    if (stream != p->real_stream)
  ------------------
  |  Branch (593:9): [True: 0, False: 40.0k]
  ------------------
  594|      0|        free_stream(stream);
  595|  40.0k|    return ret;
  596|      0|}
demux_playlist.c:get_directory_filter:
  514|  40.0k|{
  515|  40.0k|    enum autocreate_mode autocreate = AUTO_NONE;
  516|  40.0k|    if (!p->directory_filter || !p->directory_filter[0])
  ------------------
  |  Branch (516:9): [True: 0, False: 40.0k]
  |  Branch (516:33): [True: 0, False: 40.0k]
  ------------------
  517|      0|        autocreate = AUTO_ANY;
  518|  40.0k|    if (bstr_in_list0(bstr0("video"), p->directory_filter))
  ------------------
  |  Branch (518:9): [True: 40.0k, False: 0]
  ------------------
  519|  40.0k|        autocreate |= AUTO_VIDEO;
  520|  40.0k|    if (bstr_in_list0(bstr0("audio"), p->directory_filter))
  ------------------
  |  Branch (520:9): [True: 40.0k, False: 0]
  ------------------
  521|  40.0k|        autocreate |= AUTO_AUDIO;
  522|  40.0k|    if (bstr_in_list0(bstr0("image"), p->directory_filter))
  ------------------
  |  Branch (522:9): [True: 40.0k, False: 0]
  ------------------
  523|  40.0k|        autocreate |= AUTO_IMAGE;
  524|  40.0k|    if (bstr_in_list0(bstr0("archive"), p->directory_filter))
  ------------------
  |  Branch (524:9): [True: 40.0k, False: 0]
  ------------------
  525|  40.0k|        autocreate |= AUTO_ARCHIVE;
  526|  40.0k|    if (bstr_in_list0(bstr0("playlist"), p->directory_filter))
  ------------------
  |  Branch (526:9): [True: 40.0k, False: 0]
  ------------------
  527|  40.0k|        autocreate |= AUTO_PLAYLIST;
  528|  40.0k|    return autocreate;
  529|  40.0k|}
demux_playlist.c:probe_pl:
  625|  55.0k|{
  626|  55.0k|    int64_t start = stream_tell(p->s);
  627|  55.0k|    const struct pl_format *fmt = fmts;
  628|   185k|    while (fmt->name) {
  ------------------
  |  Branch (628:12): [True: 130k, False: 55.0k]
  ------------------
  629|   130k|        stream_seek(p->s, start);
  630|   130k|        if (check_mimetype(p->s, fmt->mime_types)) {
  ------------------
  |  Branch (630:13): [True: 0, False: 130k]
  ------------------
  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|   130k|        if (fmt->parse(p) >= 0)
  ------------------
  |  Branch (635:13): [True: 0, False: 130k]
  ------------------
  636|      0|            return fmt;
  637|   130k|        fmt++;
  638|   130k|    }
  639|  55.0k|    return NULL;
  640|  55.0k|}

demux_raw.c:demux_rawaudio_open:
  146|  40.0k|{
  147|  40.0k|    struct demux_rawaudio_opts *opts =
  148|  40.0k|        mp_get_config_group(demuxer, demuxer->global, &demux_rawaudio_conf);
  149|       |
  150|  40.0k|    if (check != DEMUX_CHECK_REQUEST && check != DEMUX_CHECK_FORCE)
  ------------------
  |  Branch (150:9): [True: 40.0k, False: 0]
  |  Branch (150:41): [True: 40.0k, False: 0]
  ------------------
  151|  40.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|  40.0k|{
  188|  40.0k|    struct demux_rawvideo_opts *opts =
  189|  40.0k|        mp_get_config_group(demuxer, demuxer->global, &demux_rawvideo_conf);
  190|       |
  191|  40.0k|    if (check != DEMUX_CHECK_REQUEST && check != DEMUX_CHECK_FORCE)
  ------------------
  |  Branch (191:9): [True: 40.0k, False: 0]
  |  Branch (191:41): [True: 40.0k, False: 0]
  ------------------
  192|  40.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|}

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

ebml_is_mkv_level1_id:
   41|  9.99k|{
   42|  9.99k|    switch (id) {
   43|    648|    case MATROSKA_ID_SEEKHEAD:
  ------------------
  |  |   14|    648|#define MATROSKA_ID_SEEKHEAD                     0x114d9b74
  ------------------
  |  Branch (43:5): [True: 648, False: 9.34k]
  ------------------
   44|  1.64k|    case MATROSKA_ID_INFO:
  ------------------
  |  |   18|  1.64k|#define MATROSKA_ID_INFO                         0x1549a966
  ------------------
  |  Branch (44:5): [True: 995, False: 8.99k]
  ------------------
   45|  1.64k|    case MATROSKA_ID_CLUSTER:
  ------------------
  |  |   28|  1.64k|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (45:5): [True: 0, False: 9.99k]
  ------------------
   46|  2.49k|    case MATROSKA_ID_TRACKS:
  ------------------
  |  |   40|  2.49k|#define MATROSKA_ID_TRACKS                       0x1654ae6b
  ------------------
  |  Branch (46:5): [True: 851, False: 9.13k]
  ------------------
   47|  2.50k|    case MATROSKA_ID_CUES:
  ------------------
  |  |  130|  2.50k|#define MATROSKA_ID_CUES                         0x1c53bb6b
  ------------------
  |  Branch (47:5): [True: 9, False: 9.98k]
  ------------------
   48|  2.50k|    case MATROSKA_ID_ATTACHMENTS:
  ------------------
  |  |  138|  2.50k|#define MATROSKA_ID_ATTACHMENTS                  0x1941a469
  ------------------
  |  Branch (48:5): [True: 2, False: 9.98k]
  ------------------
   49|  2.50k|    case MATROSKA_ID_CHAPTERS:
  ------------------
  |  |  145|  2.50k|#define MATROSKA_ID_CHAPTERS                     0x1043a770
  ------------------
  |  Branch (49:5): [True: 0, False: 9.99k]
  ------------------
   50|  2.50k|    case MATROSKA_ID_TAGS:
  ------------------
  |  |  164|  2.50k|#define MATROSKA_ID_TAGS                         0x1254c367
  ------------------
  |  Branch (50:5): [True: 0, False: 9.99k]
  ------------------
   51|  2.50k|        return true;
   52|  7.48k|    default:
  ------------------
  |  Branch (52:5): [True: 7.48k, False: 2.50k]
  ------------------
   53|       |        return false;
   54|  9.99k|    }
   55|  9.99k|}
ebml_read_id:
   62|  75.3k|{
   63|  75.3k|    int i, len_mask = 0x80;
   64|  75.3k|    uint32_t id;
   65|       |
   66|   196k|    for (i = 0, id = stream_read_char(s); i < 4 && !(id & len_mask); i++)
  ------------------
  |  Branch (66:43): [True: 180k, False: 16.0k]
  |  Branch (66:52): [True: 120k, False: 59.2k]
  ------------------
   67|   120k|        len_mask >>= 1;
   68|  75.3k|    if (i >= 4)
  ------------------
  |  Branch (68:9): [True: 16.0k, False: 59.2k]
  ------------------
   69|  16.0k|        return EBML_ID_INVALID;
  ------------------
  |  |   75|  16.0k|#define EBML_ID_INVALID 0xffffffff
  ------------------
   70|   115k|    while (i--)
  ------------------
  |  Branch (70:12): [True: 56.6k, False: 59.2k]
  ------------------
   71|  56.6k|        id = (id << 8) | stream_read_char(s);
   72|  59.2k|    return id;
   73|  75.3k|}
ebml_read_length:
   79|  36.7k|{
   80|  36.7k|    int byte = stream_read_char(s);
   81|  36.7k|    if (byte == STREAM_EOF || byte < 1)
  ------------------
  |  |   71|  73.5k|#define STREAM_EOF (-256)
  ------------------
  |  Branch (81:9): [True: 21, False: 36.7k]
  |  Branch (81:31): [True: 744, False: 36.0k]
  ------------------
   82|    765|        return EBML_UINT_INVALID;
  ------------------
  |  |   85|    765|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
   83|       |
   84|  36.0k|    uint8_t leading_zeros = 7 - mp_log2((uint8_t)byte);
   85|  36.0k|    uint64_t len = (uint8_t)byte & ((1 << (8 - leading_zeros - 1)) - 1);
   86|  73.7k|    for (uint8_t i = 0; i < leading_zeros; ++i) {
  ------------------
  |  Branch (86:25): [True: 37.7k, False: 35.9k]
  ------------------
   87|  37.7k|        byte = stream_read_char(s);
   88|  37.7k|        if (byte == STREAM_EOF)
  ------------------
  |  |   71|  37.7k|#define STREAM_EOF (-256)
  ------------------
  |  Branch (88:13): [True: 20, False: 37.7k]
  ------------------
   89|     20|            return EBML_UINT_INVALID;
  ------------------
  |  |   85|     20|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
   90|  37.7k|        len = (len << 8) | (uint8_t)byte;
   91|  37.7k|    }
   92|       |
   93|  35.9k|    return len;
   94|  36.0k|}
ebml_read_signed_length:
  100|  9.24k|{
  101|  9.24k|    uint64_t unum;
  102|  9.24k|    int l;
  103|       |
  104|       |    /* read as unsigned number first */
  105|  9.24k|    uint64_t offset = stream_tell(s);
  106|  9.24k|    unum = ebml_read_length(s);
  107|  9.24k|    if (unum == EBML_UINT_INVALID)
  ------------------
  |  |   85|  9.24k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (107:9): [True: 138, False: 9.10k]
  ------------------
  108|    138|        return EBML_INT_INVALID;
  ------------------
  |  |   86|    138|#define EBML_INT_INVALID    INT64_MAX
  ------------------
  109|  9.10k|    l = stream_tell(s) - offset;
  110|       |
  111|  9.10k|    return unum - ((1LL << ((7 * l) - 1)) - 1);
  112|  9.24k|}
ebml_read_uint:
  118|  3.40k|{
  119|  3.40k|    uint64_t len, value = 0;
  120|       |
  121|  3.40k|    len = ebml_read_length(s);
  122|  3.40k|    if (len == EBML_UINT_INVALID || len > 8)
  ------------------
  |  |   85|  6.81k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (122:9): [True: 19, False: 3.38k]
  |  Branch (122:37): [True: 126, False: 3.26k]
  ------------------
  123|    145|        return false;
  124|       |
  125|  6.60k|    while (len--)
  ------------------
  |  Branch (125:12): [True: 3.34k, False: 3.26k]
  ------------------
  126|  3.34k|        value = (value << 8) | stream_read_char(s);
  127|       |
  128|  3.26k|    *out = value;
  129|       |    return true;
  130|  3.40k|}
ebml_read_int:
  136|     19|{
  137|     19|    uint64_t value = 0;
  138|     19|    uint64_t len;
  139|     19|    int l;
  140|       |
  141|     19|    len = ebml_read_length(s);
  142|     19|    if (len == EBML_UINT_INVALID || len > 8)
  ------------------
  |  |   85|     38|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (142:9): [True: 1, False: 18]
  |  Branch (142:37): [True: 18, False: 0]
  ------------------
  143|     19|        return false;
  144|      0|    if (!len) {
  ------------------
  |  Branch (144:9): [True: 0, False: 0]
  ------------------
  145|      0|        *out = 0;
  146|      0|        return true;
  147|      0|    }
  148|       |
  149|      0|    len--;
  150|      0|    l = stream_read_char(s);
  151|      0|    if (l & 0x80)
  ------------------
  |  Branch (151:9): [True: 0, False: 0]
  ------------------
  152|      0|        value = -1;
  153|      0|    value = (value << 8) | l;
  154|      0|    while (len--)
  ------------------
  |  Branch (154:12): [True: 0, False: 0]
  ------------------
  155|      0|        value = (value << 8) | stream_read_char(s);
  156|       |
  157|      0|    *out = (int64_t)value; // assume complement of 2
  158|       |    return true;
  159|      0|}
ebml_read_skip:
  166|  10.9k|{
  167|  10.9k|    uint64_t len;
  168|       |
  169|  10.9k|    int64_t pos = stream_tell(s);
  170|       |
  171|  10.9k|    len = ebml_read_length(s);
  172|  10.9k|    if (len == EBML_UINT_INVALID)
  ------------------
  |  |   85|  10.9k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (172:9): [True: 347, False: 10.5k]
  ------------------
  173|    347|        goto invalid;
  174|       |
  175|  10.5k|    int64_t pos2 = stream_tell(s);
  176|  10.5k|    if (len >= INT64_MAX - pos2 || (end > 0 && pos2 + len > end))
  ------------------
  |  Branch (176:9): [True: 0, False: 10.5k]
  |  Branch (176:37): [True: 6.74k, False: 3.81k]
  |  Branch (176:48): [True: 285, False: 6.46k]
  ------------------
  177|    285|        goto invalid;
  178|       |
  179|  10.2k|    if (!stream_seek_skip(s, pos2 + len))
  ------------------
  |  Branch (179:9): [True: 1.98k, False: 8.29k]
  ------------------
  180|  1.98k|        goto invalid;
  181|       |
  182|  8.29k|    return 0;
  183|       |
  184|  2.61k|invalid:
  185|  2.61k|    mp_err(log, "Invalid EBML length at position %"PRId64"\n", pos);
  ------------------
  |  |   76|  2.61k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  186|  2.61k|    stream_seek_skip(s, pos);
  187|  2.61k|    return 1;
  188|  10.2k|}
ebml_resync_cluster:
  194|  3.59k|{
  195|  3.59k|    int64_t pos = stream_tell(s);
  196|  3.59k|    uint32_t last_4_bytes = 0;
  197|  3.59k|    stream_read_peek(s, &(char){0}, 1);
  198|  3.59k|    if (!s->eof) {
  ------------------
  |  Branch (198:9): [True: 3.59k, False: 0]
  ------------------
  199|  3.59k|        mp_err(log, "Corrupt file detected. "
  ------------------
  |  |   76|  3.59k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  200|  3.59k|               "Trying to resync starting from position %"PRId64"...\n", pos);
  201|  3.59k|    }
  202|  1.11M|    while (!s->eof) {
  ------------------
  |  Branch (202:12): [True: 1.11M, False: 161]
  ------------------
  203|       |        // Assumes MATROSKA_ID_CLUSTER is 4 bytes, with no 0 bytes.
  204|  1.11M|        if (last_4_bytes == MATROSKA_ID_CLUSTER) {
  ------------------
  |  |   28|  1.11M|#define MATROSKA_ID_CLUSTER                      0x1f43b675
  ------------------
  |  Branch (204:13): [True: 3.43k, False: 1.10M]
  ------------------
  205|  3.43k|            mp_err(log, "Cluster found at %"PRId64".\n", pos - 4);
  ------------------
  |  |   76|  3.43k|#define mp_err(log, ...)        mp_msg(log, MSGL_ERR, __VA_ARGS__)
  ------------------
  206|  3.43k|            stream_seek(s, pos - 4);
  207|  3.43k|            return 0;
  208|  3.43k|        }
  209|  1.10M|        last_4_bytes = (last_4_bytes << 8) | stream_read_char(s);
  210|  1.10M|        pos++;
  211|  1.10M|    }
  212|    161|    return -1;
  213|  3.59k|}
ebml_read_element:
  613|  3.41k|{
  614|  3.41k|    ctx->has_errors = false;
  615|  3.41k|    int msglevel = ctx->no_error_messages ? MSGL_DEBUG : MSGL_WARN;
  ------------------
  |  Branch (615:20): [True: 1.90k, False: 1.50k]
  ------------------
  616|  3.41k|    uint64_t length = ebml_read_length(s);
  617|  3.41k|    if (s->eof) {
  ------------------
  |  Branch (617:9): [True: 4, False: 3.40k]
  ------------------
  618|      4|        MP_MSG(ctx, msglevel, "Unexpected end of file "
  ------------------
  |  |   86|      4|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  619|      4|                   "- partial or corrupt file?\n");
  620|      4|        return -1;
  621|      4|    }
  622|  3.40k|    if (length == EBML_UINT_INVALID) {
  ------------------
  |  |   85|  3.40k|#define EBML_UINT_INVALID   UINT64_MAX
  ------------------
  |  Branch (622:9): [True: 34, False: 3.37k]
  ------------------
  623|     34|        MP_MSG(ctx, msglevel, "EBML element with unknown length - unsupported\n");
  ------------------
  |  |   86|     34|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  624|     34|        return -1;
  625|     34|    }
  626|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  627|       |    if (length > (512 << 20)) {
  628|       |#else
  629|  3.37k|    if (length > (64 << 20)) {
  ------------------
  |  Branch (629:9): [True: 130, False: 3.24k]
  ------------------
  630|    130|#endif
  631|    130|        MP_MSG(ctx, msglevel, "Element too big (%" PRIu64 " MiB) - skipping\n", length >> 20);
  ------------------
  |  |   86|    130|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  632|    130|        return -1;
  633|    130|    }
  634|  3.24k|    ctx->talloc_ctx = talloc_size(NULL, length);
  ------------------
  |  |   43|  3.24k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  3.24k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  3.24k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  3.24k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  3.24k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.24k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  635|  3.24k|    int read_len = stream_read(s, ctx->talloc_ctx, length);
  636|  3.24k|    if (read_len < length)
  ------------------
  |  Branch (636:9): [True: 347, False: 2.89k]
  ------------------
  637|    347|        MP_MSG(ctx, msglevel, "Unexpected end of file - partial or corrupt file?\n");
  ------------------
  |  |   86|    347|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  638|  3.24k|    ebml_parse_element(ctx, target, ctx->talloc_ctx, read_len, desc, 0);
  639|  3.24k|    if (ctx->has_errors)
  ------------------
  |  Branch (639:9): [True: 1.76k, False: 1.47k]
  ------------------
  640|  1.76k|        MP_MSG(ctx, msglevel, "Error parsing element %s\n", desc->name);
  ------------------
  |  |   86|  1.76k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  ------------------
  641|  3.24k|    return 0;
  642|  3.37k|}
ebml.c:ebml_parse_element:
  327|  5.43k|{
  328|  5.43k|    mp_assert(type->type == EBML_TYPE_SUBELEMENTS);
  ------------------
  |  |   41|  5.43k|#define mp_assert assert
  ------------------
  |  Branch (328:5): [True: 5.43k, False: 0]
  ------------------
  329|  5.43k|    mp_assert(level < 8);
  ------------------
  |  |   41|  5.43k|#define mp_assert assert
  ------------------
  |  Branch (329:5): [True: 5.43k, False: 0]
  ------------------
  330|  5.43k|    MP_TRACE(ctx, "%.*sParsing element %s\n", level, "       ", type->name);
  ------------------
  |  |   94|  5.43k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  5.43k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  331|       |
  332|  5.43k|    char *s = target;
  333|  5.43k|    uint8_t *end = data + size;
  334|  5.43k|    uint8_t *p = data;
  335|  5.43k|    int num_elems[MAX_EBML_SUBELEMENTS] = {0};
  336|  29.1k|    while (p < end) {
  ------------------
  |  Branch (336:12): [True: 24.7k, False: 4.42k]
  ------------------
  337|  24.7k|        uint8_t *startp = p;
  338|  24.7k|        int len;
  339|  24.7k|        uint32_t id = ebml_parse_id(p, end - p, &len);
  340|  24.7k|        if (len > end - p)
  ------------------
  |  Branch (340:13): [True: 24, False: 24.7k]
  ------------------
  341|     24|            goto past_end_error;
  342|  24.7k|        if (len < 0) {
  ------------------
  |  Branch (342:13): [True: 218, False: 24.5k]
  ------------------
  343|    218|            MP_ERR(ctx, "Error parsing subelement id\n");
  ------------------
  |  |   89|    218|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    218|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  344|    218|            goto other_error;
  345|    218|        }
  346|  24.5k|        p += len;
  347|  24.5k|        uint64_t length = ebml_parse_length(p, end - p, &len);
  348|  24.5k|        if (len > end - p)
  ------------------
  |  Branch (348:13): [True: 0, False: 24.5k]
  ------------------
  349|      0|            goto past_end_error;
  350|  24.5k|        if (len < 0) {
  ------------------
  |  Branch (350:13): [True: 209, False: 24.2k]
  ------------------
  351|    209|            MP_ERR(ctx, "Error parsing subelement length\n");
  ------------------
  |  |   89|    209|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    209|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  352|    209|            goto other_error;
  353|    209|        }
  354|  24.2k|        p += len;
  355|       |
  356|  24.2k|        int field_idx = -1;
  357|   124k|        for (int i = 0; i < type->field_count; i++)
  ------------------
  |  Branch (357:25): [True: 121k, False: 3.27k]
  ------------------
  358|   121k|            if (type->fields[i].id == id) {
  ------------------
  |  Branch (358:17): [True: 21.0k, False: 100k]
  ------------------
  359|  21.0k|                field_idx = i;
  360|  21.0k|                num_elems[i]++;
  361|  21.0k|                if (num_elems[i] >= 0x70000000) {
  ------------------
  |  Branch (361:21): [True: 0, False: 21.0k]
  ------------------
  362|      0|                    MP_ERR(ctx, "Too many EBML subelements.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  363|      0|                    goto other_error;
  364|      0|                }
  365|  21.0k|                break;
  366|  21.0k|            }
  367|       |
  368|  24.2k|        if (length > end - p) {
  ------------------
  |  Branch (368:13): [True: 1.65k, False: 22.6k]
  ------------------
  369|  1.65k|            if (field_idx >= 0 && type->fields[field_idx].desc->type
  ------------------
  |  Branch (369:17): [True: 608, False: 1.04k]
  |  Branch (369:35): [True: 555, False: 53]
  ------------------
  370|    608|                != EBML_TYPE_SUBELEMENTS) {
  371|    555|                MP_ERR(ctx, "Subelement content goes "
  ------------------
  |  |   89|    555|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    555|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  372|    555|                       "past end of containing element\n");
  373|    555|                goto other_error;
  374|    555|            }
  375|       |            // Try to parse what is possible from inside this partial element
  376|  1.09k|            ctx->has_errors = true;
  377|  1.09k|            length = end - p;
  378|  1.09k|        }
  379|  23.7k|        p += length;
  380|       |
  381|  23.7k|        continue;
  382|       |
  383|     24|    past_end_error:
  384|     24|        MP_ERR(ctx, "Subelement headers go past end of containing element\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__)
  |  |  ------------------
  ------------------
  385|  1.00k|    other_error:
  386|  1.00k|        ctx->has_errors = true;
  387|  1.00k|        end = startp;
  388|  1.00k|        break;
  389|     24|    }
  390|       |
  391|  45.7k|    for (int i = 0; i < type->field_count; i++) {
  ------------------
  |  Branch (391:21): [True: 40.3k, False: 5.43k]
  ------------------
  392|  40.3k|        if (num_elems[i] && type->fields[i].multiple) {
  ------------------
  |  Branch (392:13): [True: 19.8k, False: 20.5k]
  |  Branch (392:29): [True: 861, False: 18.9k]
  ------------------
  393|    861|            char *ptr = s + type->fields[i].offset;
  394|    861|            switch (type->fields[i].desc->type) {
  395|    861|            case EBML_TYPE_SUBELEMENTS: {
  ------------------
  |  Branch (395:13): [True: 861, False: 0]
  ------------------
  396|    861|                size_t max = 1000000000 / type->fields[i].desc->size;
  397|    861|                if (num_elems[i] > max) {
  ------------------
  |  Branch (397:21): [True: 0, False: 861]
  ------------------
  398|      0|                    MP_ERR(ctx, "Too many subelements.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  399|      0|                    num_elems[i] = max;
  400|      0|                }
  401|    861|                int sz = num_elems[i] * type->fields[i].desc->size;
  402|    861|                *(generic_struct **) ptr = talloc_zero_size(ctx->talloc_ctx, sz);
  ------------------
  |  |   44|    861|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|    861|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    861|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|    861|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|    861|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|    861|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|    861|                break;
  404|      0|            }
  405|      0|            case EBML_TYPE_UINT:
  ------------------
  |  Branch (405:13): [True: 0, False: 861]
  ------------------
  406|      0|                *(uint64_t **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  407|      0|                                                       uint64_t, num_elems[i]);
  408|      0|                break;
  409|      0|            case EBML_TYPE_SINT:
  ------------------
  |  Branch (409:13): [True: 0, False: 861]
  ------------------
  410|      0|                *(int64_t **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|      0|                                                      int64_t, num_elems[i]);
  412|      0|                break;
  413|      0|            case EBML_TYPE_FLOAT:
  ------------------
  |  Branch (413:13): [True: 0, False: 861]
  ------------------
  414|      0|                *(double **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|      0|                                                     double, num_elems[i]);
  416|      0|                break;
  417|      0|            case EBML_TYPE_STR:
  ------------------
  |  Branch (417:13): [True: 0, False: 861]
  ------------------
  418|      0|                *(char ***) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  419|      0|                                                    char *, num_elems[i]);
  420|      0|                break;
  421|      0|            case EBML_TYPE_BINARY:
  ------------------
  |  Branch (421:13): [True: 0, False: 861]
  ------------------
  422|      0|                *(struct bstr **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|      0|                                                          struct bstr,
  424|      0|                                                          num_elems[i]);
  425|      0|                break;
  426|      0|            case EBML_TYPE_EBML_ID:
  ------------------
  |  Branch (426:13): [True: 0, False: 861]
  ------------------
  427|      0|                *(int32_t **) ptr = talloc_zero_array(ctx->talloc_ctx,
  ------------------
  |  |   30|      0|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|      0|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|      0|                                                      uint32_t, num_elems[i]);
  429|      0|                break;
  430|      0|            default:
  ------------------
  |  Branch (430:13): [True: 0, False: 861]
  ------------------
  431|    861|                MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (431:17): [Folded, False: 0]
  ------------------
  432|    861|            }
  433|    861|        }
  434|  40.3k|    }
  435|       |
  436|  29.1k|    while (data < end) {
  ------------------
  |  Branch (436:12): [True: 23.7k, False: 5.43k]
  ------------------
  437|  23.7k|        int len;
  438|  23.7k|        uint32_t id = ebml_parse_id(data, end - data, &len);
  439|  23.7k|        if (len < 0 || len > end - data) {
  ------------------
  |  Branch (439:13): [True: 0, False: 23.7k]
  |  Branch (439:24): [True: 0, False: 23.7k]
  ------------------
  440|      0|            MP_ERR(ctx, "Error parsing subelement\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  441|      0|            break;
  442|      0|        }
  443|  23.7k|        data += len;
  444|  23.7k|        uint64_t length = ebml_parse_length(data, end - data, &len);
  445|  23.7k|        if (len < 0 || len > end - data) {
  ------------------
  |  Branch (445:13): [True: 0, False: 23.7k]
  |  Branch (445:24): [True: 0, False: 23.7k]
  ------------------
  446|      0|            MP_ERR(ctx, "Error parsing subelement length\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  447|      0|            break;
  448|      0|        }
  449|  23.7k|        data += len;
  450|  23.7k|        if (length > end - data) {
  ------------------
  |  Branch (450:13): [True: 1.09k, False: 22.6k]
  ------------------
  451|       |            // Try to parse what is possible from inside this partial element
  452|  1.09k|            length = end - data;
  453|  1.09k|            MP_ERR(ctx, "Next subelement content goes "
  ------------------
  |  |   89|  1.09k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.09k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  454|  1.09k|                   "past end of containing element, will be truncated\n");
  455|  1.09k|        }
  456|  23.7k|        int field_idx = -1;
  457|   123k|        for (int i = 0; i < type->field_count; i++)
  ------------------
  |  Branch (457:25): [True: 120k, False: 3.27k]
  ------------------
  458|   120k|            if (type->fields[i].id == id) {
  ------------------
  |  Branch (458:17): [True: 20.4k, False: 99.6k]
  ------------------
  459|  20.4k|                field_idx = i;
  460|  20.4k|                break;
  461|  20.4k|            }
  462|  23.7k|        if (field_idx < 0) {
  ------------------
  |  Branch (462:13): [True: 3.27k, False: 20.4k]
  ------------------
  463|  3.27k|            if (id == 0xec) {
  ------------------
  |  Branch (463:17): [True: 4, False: 3.27k]
  ------------------
  464|      4|                MP_TRACE(ctx, "%.*sIgnoring Void element "
  ------------------
  |  |   94|      4|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      4|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  465|      4|                         "size: %"PRIu64"\n", level+1, "        ", length);
  466|  3.27k|            } else if (id == 0xbf) {
  ------------------
  |  Branch (466:24): [True: 1.35k, False: 1.92k]
  ------------------
  467|  1.35k|                MP_TRACE(ctx, "%.*sIgnoring CRC-32 "
  ------------------
  |  |   94|  1.35k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.35k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  468|  1.35k|                         "element size: %"PRIu64"\n", level+1, "        ",
  469|  1.35k|                         length);
  470|  1.92k|            } else {
  471|  1.92k|                MP_DBG(ctx, "Ignoring unrecognized "
  ------------------
  |  |   93|  1.92k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.92k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  472|  1.92k|                       "subelement. ID: %x size: %"PRIu64"\n", id, length);
  473|  1.92k|            }
  474|  3.27k|            data += length;
  475|  3.27k|            continue;
  476|  3.27k|        }
  477|  20.4k|        const struct ebml_field_desc *fd = &type->fields[field_idx];
  478|  20.4k|        const struct ebml_elem_desc *ed = fd->desc;
  479|  20.4k|        bool multiple = fd->multiple;
  480|  20.4k|        int *countptr = (int *) (s + fd->count_offset);
  481|  20.4k|        if (*countptr >= num_elems[field_idx]) {
  ------------------
  |  Branch (481:13): [True: 0, False: 20.4k]
  ------------------
  482|       |            // Shouldn't happen on any sane file without bugs
  483|      0|            MP_ERR(ctx, "Too many subelements.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  484|      0|            ctx->has_errors = true;
  485|      0|            data += length;
  486|      0|            continue;
  487|      0|        }
  488|  20.4k|        if (*countptr > 0 && !multiple) {
  ------------------
  |  Branch (488:13): [True: 1.18k, False: 19.2k]
  |  Branch (488:30): [True: 49, False: 1.13k]
  ------------------
  489|     49|            MP_WARN(ctx, "Another subelement of type "
  ------------------
  |  |   90|     49|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     49|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|     49|                    "%x %s (size: %"PRIu64"). Only one allowed. Ignoring.\n",
  491|     49|                    id, ed->name, length);
  492|     49|            ctx->has_errors = true;
  493|     49|            data += length;
  494|     49|            continue;
  495|     49|        }
  496|  20.4k|        MP_TRACE(ctx, "%.*sParsing %x %s size: %"PRIu64
  ------------------
  |  |   94|  20.4k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  20.4k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  497|  20.4k|                 " value: ", level+1, "        ", id, ed->name, length);
  498|       |
  499|  20.4k|        char *fieldptr = s + fd->offset;
  500|  20.4k|        switch (ed->type) {
  501|  2.18k|        case EBML_TYPE_SUBELEMENTS:
  ------------------
  |  Branch (501:9): [True: 2.18k, False: 18.2k]
  ------------------
  502|  2.18k|            MP_TRACE(ctx, "subelements\n");
  ------------------
  |  |   94|  2.18k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.18k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  503|  2.18k|            char *subelptr;
  504|  2.18k|            if (multiple) {
  ------------------
  |  Branch (504:17): [True: 1.99k, False: 192]
  ------------------
  505|  1.99k|                char *array_start = (char *) *(generic_struct **) fieldptr;
  506|  1.99k|                subelptr = array_start + *countptr * ed->size;
  507|  1.99k|            } else
  508|    192|                subelptr = fieldptr;
  509|  2.18k|            ebml_parse_element(ctx, subelptr, data, length, ed, level + 1);
  510|  2.18k|            break;
  511|       |
  512|  13.2k|        case EBML_TYPE_UINT:;
  ------------------
  |  Branch (512:9): [True: 13.2k, False: 7.17k]
  ------------------
  513|  13.2k|            uint64_t *uintptr;
  514|  13.2k|#define GETPTR(subelptr, fieldtype)                                     \
  515|  13.2k|            if (multiple)                                               \
  516|  13.2k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  517|  13.2k|            else                                                        \
  518|  13.2k|                subelptr = (fieldtype *) fieldptr
  519|  13.2k|            GETPTR(uintptr, uint64_t);
  ------------------
  |  |  515|  13.2k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 13.2k]
  |  |  ------------------
  |  |  516|  13.2k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|  13.2k|            else                                                        \
  |  |  518|  13.2k|                subelptr = (fieldtype *) fieldptr
  ------------------
  520|  13.2k|            if (length > 8) {
  ------------------
  |  Branch (520:17): [True: 10, False: 13.2k]
  ------------------
  521|     10|                MP_ERR(ctx, "uint invalid length %"PRIu64"\n", length);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  522|     10|                goto error;
  523|     10|            }
  524|  13.2k|            if (!length && ed->context_default)
  ------------------
  |  Branch (524:17): [True: 20, False: 13.2k]
  |  Branch (524:28): [True: 1, False: 19]
  ------------------
  525|      1|                goto skip;
  526|  13.2k|            *uintptr = length ? ebml_parse_uint(data, length) : ed->defval.u;
  ------------------
  |  Branch (526:24): [True: 13.2k, False: 19]
  ------------------
  527|  13.2k|            MP_TRACE(ctx, "uint %"PRIu64"\n", *uintptr);
  ------------------
  |  |   94|  13.2k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  13.2k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  528|  13.2k|            break;
  529|       |
  530|    287|        case EBML_TYPE_SINT:;
  ------------------
  |  Branch (530:9): [True: 287, False: 20.1k]
  ------------------
  531|    287|            int64_t *sintptr;
  532|    287|            GETPTR(sintptr, int64_t);
  ------------------
  |  |  515|    287|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 287]
  |  |  ------------------
  |  |  516|    287|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|    287|            else                                                        \
  |  |  518|    287|                subelptr = (fieldtype *) fieldptr
  ------------------
  533|    287|            if (length > 8) {
  ------------------
  |  Branch (533:17): [True: 1, False: 286]
  ------------------
  534|      1|                MP_ERR(ctx, "sint invalid length %"PRIu64"\n", length);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  535|      1|                goto error;
  536|      1|            }
  537|    286|            if (!length && ed->context_default)
  ------------------
  |  Branch (537:17): [True: 1, False: 285]
  |  Branch (537:28): [True: 0, False: 1]
  ------------------
  538|      0|                goto skip;
  539|    286|            *sintptr = length ? ebml_parse_sint(data, length) : ed->defval.i;
  ------------------
  |  Branch (539:24): [True: 285, False: 1]
  ------------------
  540|    286|            MP_TRACE(ctx, "sint %"PRId64"\n", *sintptr);
  ------------------
  |  |   94|    286|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    286|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  541|    286|            break;
  542|       |
  543|    256|        case EBML_TYPE_FLOAT:;
  ------------------
  |  Branch (543:9): [True: 256, False: 20.1k]
  ------------------
  544|    256|            double *floatptr;
  545|    256|            GETPTR(floatptr, double);
  ------------------
  |  |  515|    256|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 256]
  |  |  ------------------
  |  |  516|    256|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|    256|            else                                                        \
  |  |  518|    256|                subelptr = (fieldtype *) fieldptr
  ------------------
  546|    256|            if (length != 0 && length != 4 && length != 8) {
  ------------------
  |  Branch (546:17): [True: 250, False: 6]
  |  Branch (546:32): [True: 1, False: 249]
  |  Branch (546:47): [True: 1, False: 0]
  ------------------
  547|      1|                MP_ERR(ctx, "float invalid length %"PRIu64"\n", length);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
  548|      1|                goto error;
  549|      1|            }
  550|    255|            if (!length && ed->context_default)
  ------------------
  |  Branch (550:17): [True: 6, False: 249]
  |  Branch (550:28): [True: 0, False: 6]
  ------------------
  551|      0|                goto skip;
  552|    255|            *floatptr = length ? ebml_parse_float(data, length) : ed->defval.f;
  ------------------
  |  Branch (552:25): [True: 249, False: 6]
  ------------------
  553|    255|            MP_DBG(ctx, "float %f\n", *floatptr);
  ------------------
  |  |   93|    255|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    255|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  554|    255|            break;
  555|       |
  556|  2.69k|        case EBML_TYPE_STR:
  ------------------
  |  Branch (556:9): [True: 2.69k, False: 17.7k]
  ------------------
  557|  2.69k|            if (length > 1024 * 1024) {
  ------------------
  |  Branch (557:17): [True: 0, False: 2.69k]
  ------------------
  558|      0|                MP_ERR(ctx, "Not reading overly long string element.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  559|      0|                goto error;
  560|      0|            }
  561|  2.69k|            char **strptr;
  562|  2.69k|            GETPTR(strptr, char *);
  ------------------
  |  |  515|  2.69k|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 2.69k]
  |  |  ------------------
  |  |  516|  2.69k|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|  2.69k|            else                                                        \
  |  |  518|  2.69k|                subelptr = (fieldtype *) fieldptr
  ------------------
  563|  2.69k|            if (!length && ed->context_default)
  ------------------
  |  Branch (563:17): [True: 3, False: 2.69k]
  |  Branch (563:28): [True: 0, False: 3]
  ------------------
  564|      0|                goto skip;
  565|  2.69k|            if (!length && ed->defval.s) {
  ------------------
  |  Branch (565:17): [True: 3, False: 2.69k]
  |  Branch (565:28): [True: 0, False: 3]
  ------------------
  566|      0|                *strptr = talloc_strdup(ctx->talloc_ctx, ed->defval.s);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  567|  2.69k|            } else {
  568|  2.69k|                *strptr = talloc_strndup(ctx->talloc_ctx, data, length);
  ------------------
  |  |   51|  2.69k|#define talloc_strndup                  ta_xstrndup
  ------------------
  569|  2.69k|            }
  570|  2.69k|            MP_TRACE(ctx, "string \"%s\"\n", *strptr);
  ------------------
  |  |   94|  2.69k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  2.69k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  571|  2.69k|            break;
  572|       |
  573|    808|        case EBML_TYPE_BINARY:;
  ------------------
  |  Branch (573:9): [True: 808, False: 19.6k]
  ------------------
  574|    808|            if (length > 0x80000000) {
  ------------------
  |  Branch (574:17): [True: 0, False: 808]
  ------------------
  575|      0|                MP_ERR(ctx, "Not reading overly long EBML element.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  576|      0|                goto error;
  577|      0|            }
  578|    808|            if (ed->size && length != ed->size) {
  ------------------
  |  Branch (578:17): [True: 324, False: 484]
  |  Branch (578:29): [True: 6, False: 318]
  ------------------
  579|      6|                MP_WARN(ctx, "%s invalid length %"PRIu64", ignoring\n",
  ------------------
  |  |   90|      6|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      6|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  580|      6|                        ed->name, length);
  581|      6|                goto error;
  582|      6|            }
  583|    802|            struct bstr *binptr;
  584|    802|            GETPTR(binptr, struct bstr);
  ------------------
  |  |  515|    802|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 802]
  |  |  ------------------
  |  |  516|    802|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|    802|            else                                                        \
  |  |  518|    802|                subelptr = (fieldtype *) fieldptr
  ------------------
  585|    802|            binptr->start = data;
  586|    802|            binptr->len = length;
  587|    802|            MP_TRACE(ctx, "binary %zd bytes\n", binptr->len);
  ------------------
  |  |   94|    802|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    802|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  588|    802|            break;
  589|       |
  590|    941|        case EBML_TYPE_EBML_ID:;
  ------------------
  |  Branch (590:9): [True: 941, False: 19.4k]
  ------------------
  591|    941|            uint32_t *idptr;
  592|    941|            GETPTR(idptr, uint32_t);
  ------------------
  |  |  515|    941|            if (multiple)                                               \
  |  |  ------------------
  |  |  |  Branch (515:17): [True: 0, False: 941]
  |  |  ------------------
  |  |  516|    941|                subelptr = *(fieldtype **) fieldptr + *countptr;        \
  |  |  517|    941|            else                                                        \
  |  |  518|    941|                subelptr = (fieldtype *) fieldptr
  ------------------
  593|    941|            *idptr = ebml_parse_id(data, end - data, &len);
  594|    941|            if (len != length) {
  ------------------
  |  Branch (594:17): [True: 29, False: 912]
  ------------------
  595|     29|                MP_ERR(ctx, "ebml_id broken value\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__)
  |  |  ------------------
  ------------------
  596|     29|                goto error;
  597|     29|            }
  598|    912|            MP_TRACE(ctx, "ebml_id %x\n", (unsigned)*idptr);
  ------------------
  |  |   94|    912|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    912|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  599|    912|            break;
  600|      0|        default:
  ------------------
  |  Branch (600:9): [True: 0, False: 20.4k]
  ------------------
  601|  20.4k|            MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (601:13): [Folded, False: 0]
  ------------------
  602|  20.4k|        }
  603|  20.3k|        *countptr += 1;
  604|  20.4k|    error:
  605|  20.4k|    skip:
  606|  20.4k|        data += length;
  607|  20.4k|    }
  608|  5.43k|}
ebml.c:ebml_parse_id:
  238|  49.4k|{
  239|  49.4k|    *length = -1;
  240|  49.4k|    uint8_t *end = data + data_len;
  241|  49.4k|    if (data == end)
  ------------------
  |  Branch (241:9): [True: 1, False: 49.4k]
  ------------------
  242|      1|        return EBML_ID_INVALID;
  ------------------
  |  |   75|      1|#define EBML_ID_INVALID 0xffffffff
  ------------------
  243|  49.4k|    int len = 1;
  244|  49.4k|    uint32_t id = *data++;
  245|  90.3k|    for (int len_mask = 0x80; !(id & len_mask); len_mask >>= 1) {
  ------------------
  |  Branch (245:31): [True: 41.1k, False: 49.1k]
  ------------------
  246|  41.1k|        len++;
  247|  41.1k|        if (len > 4)
  ------------------
  |  Branch (247:13): [True: 222, False: 40.8k]
  ------------------
  248|    222|            return EBML_ID_INVALID;
  ------------------
  |  |   75|    222|#define EBML_ID_INVALID 0xffffffff
  ------------------
  249|  41.1k|    }
  250|  49.1k|    *length = len;
  251|  89.3k|    while (--len && data < end)
  ------------------
  |  Branch (251:12): [True: 40.2k, False: 49.1k]
  |  Branch (251:21): [True: 40.1k, False: 24]
  ------------------
  252|  40.1k|        id = (id << 8) | *data++;
  253|  49.1k|    return id;
  254|  49.4k|}
ebml.c:ebml_parse_length:
  257|  48.2k|{
  258|  48.2k|    *length = -1;
  259|  48.2k|    uint8_t *end = data + data_len;
  260|  48.2k|    if (data == end)
  ------------------
  |  Branch (260:9): [True: 16, False: 48.2k]
  ------------------
  261|     16|        return -1;
  262|  48.2k|    uint64_t r = *data++;
  263|  48.2k|    int len = 1;
  264|  48.2k|    int len_mask;
  265|  54.6k|    for (len_mask = 0x80; !(r & len_mask); len_mask >>= 1) {
  ------------------
  |  Branch (265:27): [True: 6.47k, False: 48.1k]
  ------------------
  266|  6.47k|        len++;
  267|  6.47k|        if (len > 8)
  ------------------
  |  Branch (267:13): [True: 61, False: 6.41k]
  ------------------
  268|     61|            return -1;
  269|  6.47k|    }
  270|  48.1k|    r &= len_mask - 1;
  271|       |
  272|  48.1k|    int num_allones = 0;
  273|  48.1k|    if (r == len_mask - 1)
  ------------------
  |  Branch (273:9): [True: 193, False: 47.9k]
  ------------------
  274|    193|        num_allones++;
  275|  54.0k|    for (int i = 1; i < len; i++) {
  ------------------
  |  Branch (275:21): [True: 5.91k, False: 48.0k]
  ------------------
  276|  5.91k|        if (data == end)
  ------------------
  |  Branch (276:13): [True: 74, False: 5.84k]
  ------------------
  277|     74|            return -1;
  278|  5.84k|        if (*data == 255)
  ------------------
  |  Branch (278:13): [True: 134, False: 5.70k]
  ------------------
  279|    134|            num_allones++;
  280|  5.84k|        r = (r << 8) | *data++;
  281|  5.84k|    }
  282|       |    // According to Matroska specs this means "unknown length"
  283|       |    // Could be supported if there are any actual files using it
  284|  48.0k|    if (num_allones == len)
  ------------------
  |  Branch (284:9): [True: 58, False: 48.0k]
  ------------------
  285|     58|        return -1;
  286|  48.0k|    *length = len;
  287|  48.0k|    return r;
  288|  48.0k|}
ebml.c:ebml_parse_uint:
  291|  13.4k|{
  292|  13.4k|    mp_assert(length >= 0 && length <= 8);
  ------------------
  |  |   41|  13.4k|#define mp_assert assert
  ------------------
  |  Branch (292:5): [True: 13.4k, False: 0]
  |  Branch (292:5): [True: 13.4k, False: 0]
  ------------------
  293|  13.4k|    uint64_t r = 0;
  294|  28.9k|    while (length--)
  ------------------
  |  Branch (294:12): [True: 15.4k, False: 13.4k]
  ------------------
  295|  15.4k|        r = (r << 8) + *data++;
  296|  13.4k|    return r;
  297|  13.4k|}
ebml.c:ebml_parse_sint:
  300|    285|{
  301|    285|    mp_assert(length >= 0 && length <= 8);
  ------------------
  |  |   41|    285|#define mp_assert assert
  ------------------
  |  Branch (301:5): [True: 285, False: 0]
  |  Branch (301:5): [True: 285, False: 0]
  ------------------
  302|    285|    if (!length)
  ------------------
  |  Branch (302:9): [True: 0, False: 285]
  ------------------
  303|      0|        return 0;
  304|    285|    uint64_t r = 0;
  305|    285|    if (*data & 0x80)
  ------------------
  |  Branch (305:9): [True: 11, False: 274]
  ------------------
  306|     11|        r = -1;
  307|  2.55k|    while (length--)
  ------------------
  |  Branch (307:12): [True: 2.26k, False: 285]
  ------------------
  308|  2.26k|        r = (r << 8) | *data++;
  309|    285|    return (int64_t)r; // assume complement of 2
  310|    285|}
ebml.c:ebml_parse_float:
  313|    249|{
  314|    249|    mp_assert(length == 0 || length == 4 || length == 8);
  ------------------
  |  |   41|    249|#define mp_assert assert
  ------------------
  |  Branch (314:5): [True: 0, False: 249]
  |  Branch (314:5): [True: 249, False: 0]
  |  Branch (314:5): [True: 0, False: 0]
  ------------------
  315|    249|    uint64_t i = ebml_parse_uint(data, length);
  316|    249|    if (length == 4)
  ------------------
  |  Branch (316:9): [True: 249, False: 0]
  ------------------
  317|    249|        return av_int2float(i);
  318|      0|    else
  319|      0|        return av_int2double(i);
  320|    249|}

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

demux_packet_pool_init:
   50|  32.5k|{
   51|  32.5k|    struct demux_packet_pool *pool = talloc(global, struct demux_packet_pool);
  ------------------
  |  |   26|  32.5k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  32.5k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   52|  32.5k|    talloc_set_destructor(pool, uninit);
  ------------------
  |  |   41|  32.5k|#define talloc_set_destructor           ta_set_destructor
  ------------------
   53|  32.5k|    mp_mutex_init(&pool->lock);
   54|  32.5k|    pool->packets = NULL;
   55|       |
   56|  32.5k|    mp_assert(!global->packet_pool);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (56:5): [True: 32.5k, False: 0]
  ------------------
   57|  32.5k|    global->packet_pool = pool;
   58|  32.5k|}
demux_packet_pool_get:
   61|  1.55M|{
   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.55M|    return global->packet_pool;
   65|  1.55M|}
demux_packet_pool_clear:
   68|  97.5k|{
   69|  97.5k|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  97.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   70|  97.5k|    struct demux_packet *dp = pool->packets;
   71|  97.5k|    pool->packets = NULL;
   72|  97.5k|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  97.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   73|  97.5k|    free_demux_packets(dp);
   74|  97.5k|}
demux_packet_pool_push:
   78|  1.79M|{
   79|  1.79M|    if (!dp)
  ------------------
  |  Branch (79:9): [True: 62.7k, False: 1.73M]
  ------------------
   80|  62.7k|        return;
   81|  1.73M|    dp->next = NULL;
   82|       |    // On single packet push, clear instantly. Unlike prepend, where multiple
   83|       |    // packets may be prepended at once, there is no performance issue with
   84|       |    // clearing a single packet here.
   85|  1.73M|    demux_packet_unref(dp);
   86|  1.73M|    demux_packet_pool_prepend(pool, dp, dp);
   87|  1.73M|}
demux_packet_pool_prepend:
   91|  1.97M|{
   92|  1.97M|    if (!head)
  ------------------
  |  Branch (92:9): [True: 244k, False: 1.73M]
  ------------------
   93|   244k|        return;
   94|  1.73M|    mp_assert(tail);
  ------------------
  |  |   41|  1.73M|#define mp_assert assert
  ------------------
  |  Branch (94:5): [True: 1.73M, False: 0]
  ------------------
   95|  1.73M|    mp_assert(head != tail ? !!head->next : !head->next);
  ------------------
  |  |   41|  1.73M|#define mp_assert assert
  ------------------
  |  Branch (95:5): [True: 0, False: 1.73M]
  |  Branch (95:5): [True: 1.73M, False: 0]
  ------------------
   96|       |
   97|  1.73M|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  1.73M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   98|  1.73M|    tail->next = pool->packets;
   99|  1.73M|    pool->packets = head;
  100|       |#if HAVE_DISABLE_PACKET_POOL
  101|       |    struct demux_packet *dp = pool->packets;
  102|       |    pool->packets = NULL;
  103|       |#endif
  104|  1.73M|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  1.73M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  105|       |
  106|       |#if HAVE_DISABLE_PACKET_POOL
  107|       |    free_demux_packets(dp);
  108|       |#endif
  109|  1.73M|}
demux_packet_pool_pop:
  145|  1.75M|{
  146|  1.75M|    mp_mutex_lock(&pool->lock);
  ------------------
  |  |  134|  1.75M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  147|  1.75M|    struct demux_packet *dp = pool->packets;
  148|  1.75M|    if (dp) {
  ------------------
  |  Branch (148:9): [True: 875k, False: 879k]
  ------------------
  149|   875k|        pool->packets = dp->next;
  150|   875k|        dp->next = NULL;
  151|   875k|    }
  152|  1.75M|    struct demux_packet *gc = pool_gc_detach(pool);
  153|  1.75M|    mp_mutex_unlock(&pool->lock);
  ------------------
  |  |  136|  1.75M|#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.75M|    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.75M|    free_demux_packets(gc);
  162|       |
  163|  1.75M|    return dp;
  164|  1.75M|}
packet_pool.c:uninit:
   34|  32.5k|{
   35|  32.5k|    struct demux_packet_pool *pool = p;
   36|  32.5k|    demux_packet_pool_clear(pool);
   37|  32.5k|    mp_mutex_destroy(&pool->lock);
  ------------------
  |  |  133|  32.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
   38|  32.5k|}
packet_pool.c:free_demux_packets:
   41|  1.85M|{
   42|  2.71M|    while (dp) {
  ------------------
  |  Branch (42:12): [True: 859k, False: 1.85M]
  ------------------
   43|   859k|        struct demux_packet *next = dp->next;
   44|   859k|        free_demux_packet(dp);
   45|   859k|        dp = next;
   46|   859k|    }
   47|  1.85M|}
packet_pool.c:pool_gc_detach:
  126|  1.75M|{
  127|  1.75M|    struct demux_packet *cat_reserve = pool->packets;
  128|  9.58M|    for (int i = 1; cat_reserve && i < POOL_HOT_RESERVE; i++)
  ------------------
  |  |  114|  8.08M|#define POOL_HOT_RESERVE 16
  ------------------
  |  Branch (128:21): [True: 8.08M, False: 1.49M]
  |  Branch (128:36): [True: 7.82M, False: 260k]
  ------------------
  129|  7.82M|        cat_reserve = cat_reserve->next;
  130|       |
  131|  1.75M|    if (!cat_reserve || !cat_reserve->next)
  ------------------
  |  Branch (131:9): [True: 1.49M, False: 260k]
  |  Branch (131:25): [True: 32.5k, False: 228k]
  ------------------
  132|  1.52M|        return NULL;
  133|       |
  134|   228k|    struct demux_packet *gc = cat_reserve->next;
  135|   228k|    struct demux_packet *cut_rest = gc;
  136|   228k|    for (int i = 1; cut_rest->next && i < POOL_GC_BATCH; i++)
  ------------------
  |  |  121|      0|#define POOL_GC_BATCH 64
  ------------------
  |  Branch (136:21): [True: 0, False: 228k]
  |  Branch (136:39): [True: 0, False: 0]
  ------------------
  137|      0|        cut_rest = cut_rest->next;
  138|       |
  139|   228k|    cat_reserve->next = cut_rest->next;
  140|       |    cut_rest->next = NULL;
  141|   228k|    return gc;
  142|  1.75M|}

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

mp_deint_create:
  211|  32.5k|{
  212|  32.5k|    struct mp_filter *f = mp_filter_create(parent, &deint_filter);
  213|  32.5k|    if (!f)
  ------------------
  |  Branch (213:9): [True: 0, False: 32.5k]
  ------------------
  214|      0|        return NULL;
  215|       |
  216|  32.5k|    struct deint_priv *p = f->priv;
  217|       |
  218|  32.5k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  219|  32.5k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  220|       |
  221|  32.5k|    p->opts = m_config_cache_alloc(f, f->global, &filter_conf);
  222|       |
  223|  32.5k|    return f;
  224|  32.5k|}
mp_autorotate_create:
  337|  32.5k|{
  338|  32.5k|    struct mp_filter *f = mp_filter_create(parent, &rotate_filter);
  339|  32.5k|    if (!f)
  ------------------
  |  Branch (339:9): [True: 0, False: 32.5k]
  ------------------
  340|      0|        return NULL;
  341|       |
  342|  32.5k|    struct rotate_priv *p = f->priv;
  343|  32.5k|    p->prev_rotate = -1;
  344|       |
  345|  32.5k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  346|  32.5k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  347|       |
  348|  32.5k|    return f;
  349|  32.5k|}
mp_autovflip_create:
  458|  32.5k|{
  459|  32.5k|    struct mp_filter *f = mp_filter_create(parent, &vflip_filter);
  460|  32.5k|    if (!f)
  ------------------
  |  Branch (460:9): [True: 0, False: 32.5k]
  ------------------
  461|      0|        return NULL;
  462|       |
  463|  32.5k|    struct vflip_priv *p = f->priv;
  464|  32.5k|    p->prev_vflip = -1;
  465|       |
  466|  32.5k|    p->sub.in = mp_filter_add_pin(f, MP_PIN_IN, "in");
  467|  32.5k|    p->sub.out = mp_filter_add_pin(f, MP_PIN_OUT, "out");
  468|       |
  469|  32.5k|    return f;
  470|  32.5k|}
f_auto_filters.c:deint_destroy:
  176|  32.5k|{
  177|  32.5k|    struct deint_priv *p = f->priv;
  178|       |
  179|  32.5k|    mp_subfilter_reset(&p->sub);
  180|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  32.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  32.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  181|  32.5k|}
f_auto_filters.c:deint_process:
   30|  1.72M|{
   31|  1.72M|    struct deint_priv *p = f->priv;
   32|       |
   33|  1.72M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (33:9): [True: 877k, False: 845k]
  ------------------
   34|   877k|        return;
   35|       |
   36|   845k|    struct mp_frame frame = p->sub.frame;
   37|       |
   38|   845k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (38:9): [True: 32.5k, False: 812k]
  ------------------
   39|  32.5k|        mp_subfilter_continue(&p->sub);
   40|  32.5k|        return;
   41|  32.5k|    }
   42|       |
   43|   812k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (43:9): [True: 0, False: 812k]
  ------------------
   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|   812k|    struct mp_image *img = frame.data;
   50|   812k|    p->interlaced_frame = img->fields & MP_IMGFIELD_INTERLACED;
  ------------------
  |  |   39|   812k|#define MP_IMGFIELD_INTERLACED 0x20
  ------------------
   51|       |
   52|   812k|    m_config_cache_update(p->opts);
   53|   812k|    struct filter_opts *opts = p->opts->opts;
   54|       |
   55|       |    // Handle deinterlace=0 case by destroying any existing filter immediately.
   56|   812k|    if (!opts->deinterlace)
  ------------------
  |  Branch (56:9): [True: 812k, False: 0]
  ------------------
   57|   812k|        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|   812k|    bool filter_needed = opts->deinterlace == 1 ||
  ------------------
  |  Branch (63:26): [True: 0, False: 812k]
  ------------------
   64|   812k|                         (opts->deinterlace == -1 && (p->interlaced_frame || p->sub.filter));
  ------------------
  |  Branch (64:27): [True: 0, False: 812k]
  |  Branch (64:55): [True: 0, False: 0]
  |  Branch (64:78): [True: 0, False: 0]
  ------------------
   65|       |
   66|       |    // If the image format changed, destroy any existing filter immediately since
   67|       |    // it may not support the new format. If we no longer need a filter, drain
   68|       |    // and destroy it gracefully.
   69|   812k|    if (img->imgfmt != p->prev_imgfmt) {
  ------------------
  |  Branch (69:9): [True: 32.5k, False: 780k]
  ------------------
   70|  32.5k|        mp_subfilter_destroy(&p->sub);
   71|  32.5k|        p->prev_imgfmt = img->imgfmt;
   72|   780k|    } else if (p->sub.filter && !filter_needed) {
  ------------------
  |  Branch (72:16): [True: 0, False: 780k]
  |  Branch (72:33): [True: 0, False: 0]
  ------------------
   73|      0|        if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (73:13): [True: 0, False: 0]
  ------------------
   74|      0|            return;
   75|      0|    }
   76|       |
   77|       |    // If no filter is needed or if the filter is already inserted and we reach
   78|       |    // this point, just continue. Otherwise, create and insert the filter.
   79|   812k|    if (!filter_needed || p->sub.filter) {
  ------------------
  |  Branch (79:9): [True: 812k, False: 0]
  |  Branch (79:27): [True: 0, False: 0]
  ------------------
   80|   812k|        mp_subfilter_continue(&p->sub);
   81|   812k|        return;
   82|   812k|    }
   83|       |
   84|      0|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (84:5): [True: 0, False: 0]
  ------------------
   85|       |
   86|      0|    char *field_parity;
   87|      0|    switch (opts->field_parity) {
   88|      0|    case MP_FIELD_PARITY_TFF:
  ------------------
  |  |   33|      0|#define MP_FIELD_PARITY_TFF 0
  ------------------
  |  Branch (88:5): [True: 0, False: 0]
  ------------------
   89|      0|        field_parity = "tff";
   90|      0|        break;
   91|      0|    case MP_FIELD_PARITY_BFF:
  ------------------
  |  |   34|      0|#define MP_FIELD_PARITY_BFF 1
  ------------------
  |  Branch (91:5): [True: 0, False: 0]
  ------------------
   92|      0|        field_parity = "bff";
   93|      0|        break;
   94|      0|    default:
  ------------------
  |  Branch (94:5): [True: 0, False: 0]
  ------------------
   95|      0|        field_parity = "auto";
   96|      0|    }
   97|       |
   98|      0|    bool has_filter = true;
   99|      0|    if (img->imgfmt == IMGFMT_VDPAU) {
  ------------------
  |  Branch (99:9): [True: 0, False: 0]
  ------------------
  100|      0|        char *args[] = {"deint", "yes",
  101|      0|                        "interlaced-only", opts->deinterlace == 1 ? "no" : "yes",
  ------------------
  |  Branch (101:44): [True: 0, False: 0]
  ------------------
  102|      0|                        "parity", field_parity, NULL};
  103|      0|        p->sub.filter =
  104|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vdpaupp", args);
  105|      0|    } else if (img->imgfmt == IMGFMT_D3D11) {
  ------------------
  |  Branch (105:16): [True: 0, False: 0]
  ------------------
  106|      0|        char *args[] = {"deint", "yes",
  107|      0|                        "interlaced-only", opts->deinterlace == 1 ? "no" : "yes",
  ------------------
  |  Branch (107:44): [True: 0, False: 0]
  ------------------
  108|      0|                        "parity", field_parity, NULL};
  109|      0|        p->sub.filter =
  110|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "d3d11vpp", args);
  111|      0|    } else if (img->imgfmt == IMGFMT_CUDA) {
  ------------------
  |  Branch (111:16): [True: 0, False: 0]
  ------------------
  112|      0|        char *args[] = {"mode", "send_field",
  113|      0|                        "deint", opts->deinterlace == 1 ? "0" : "1",
  ------------------
  |  Branch (113:34): [True: 0, False: 0]
  ------------------
  114|      0|                        "parity", field_parity, NULL};
  115|      0|        p->sub.filter =
  116|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "bwdif_cuda", args);
  117|      0|    } else if (img->imgfmt == IMGFMT_VULKAN) {
  ------------------
  |  Branch (117:16): [True: 0, False: 0]
  ------------------
  118|      0|        char *args[] = {"mode", "send_field",
  119|      0|                        "deint", opts->deinterlace == 1 ? "0" : "1",
  ------------------
  |  Branch (119:34): [True: 0, False: 0]
  ------------------
  120|      0|                        "parity", field_parity, NULL};
  121|      0|        p->sub.filter =
  122|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "bwdif_vulkan", args);
  123|      0|    } else if (img->imgfmt == IMGFMT_VAAPI) {
  ------------------
  |  Branch (123:16): [True: 0, False: 0]
  ------------------
  124|      0|        char *args[] = {"deint", "motion-adaptive",
  125|      0|                        "interlaced-only", opts->deinterlace == 1 ? "no" : "yes",
  ------------------
  |  Branch (125:44): [True: 0, False: 0]
  ------------------
  126|      0|                        "parity", field_parity, NULL};
  127|      0|        p->sub.filter =
  128|      0|            mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vavpp", args);
  129|      0|    } else {
  130|      0|        has_filter = false;
  131|      0|    }
  132|       |
  133|      0|    if (!p->sub.filter) {
  ------------------
  |  Branch (133:9): [True: 0, False: 0]
  ------------------
  134|      0|        if (has_filter)
  ------------------
  |  Branch (134:13): [True: 0, False: 0]
  ------------------
  135|      0|            MP_ERR(f, "creating deinterlacer failed\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  136|       |
  137|      0|        struct mp_filter *subf = mp_bidir_dummy_filter_create(f);
  138|      0|        struct mp_filter *filters[2] = {0};
  139|       |
  140|      0|        struct mp_autoconvert *ac = mp_autoconvert_create(subf);
  141|      0|        if (ac) {
  ------------------
  |  Branch (141:13): [True: 0, False: 0]
  ------------------
  142|      0|            filters[0] = ac->f;
  143|       |            // We know vf_bwdif does not support hw inputs.
  144|      0|            mp_autoconvert_add_all_sw_imgfmts(ac);
  145|       |
  146|      0|            if (!mp_autoconvert_probe_input_video(ac, img)) {
  ------------------
  |  Branch (146:17): [True: 0, False: 0]
  ------------------
  147|      0|                MP_ERR(f, "no deinterlace filter available for format %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  148|      0|                       mp_imgfmt_to_name(img->imgfmt));
  149|      0|                talloc_free(subf);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  150|      0|                mp_subfilter_continue(&p->sub);
  151|      0|                return;
  152|      0|            }
  153|      0|        }
  154|       |
  155|      0|        char *args[] = {"mode", "send_field",
  156|      0|                        "deint", opts->deinterlace == 1 ? "0" : "1",
  ------------------
  |  Branch (156:34): [True: 0, False: 0]
  ------------------
  157|      0|                        "parity", field_parity, NULL};
  158|      0|        filters[1] =
  159|      0|            mp_create_user_filter(subf, MP_OUTPUT_CHAIN_VIDEO, "bwdif", args);
  160|       |
  161|      0|        mp_chain_filters(subf->ppins[0], subf->ppins[1], filters, 2);
  162|      0|        p->sub.filter = subf;
  163|      0|    }
  164|       |
  165|      0|    mp_subfilter_continue(&p->sub);
  166|      0|}
f_auto_filters.c:deint_command:
  184|   845k|{
  185|   845k|    struct deint_priv *p = f->priv;
  186|       |
  187|   845k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (187:9): [True: 845k, False: 0]
  ------------------
  188|   845k|        cmd->is_active = !!p->sub.filter;
  189|   845k|        return true;
  190|   845k|    }
  191|      0|    return false;
  192|   845k|}
f_auto_filters.c:rotate_destroy:
  309|  32.5k|{
  310|  32.5k|    struct rotate_priv *p = f->priv;
  311|       |
  312|  32.5k|    mp_subfilter_reset(&p->sub);
  313|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  32.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  32.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  314|  32.5k|}
f_auto_filters.c:rotate_process:
  234|  1.72M|{
  235|  1.72M|    struct rotate_priv *p = f->priv;
  236|       |
  237|  1.72M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (237:9): [True: 877k, False: 845k]
  ------------------
  238|   877k|        return;
  239|       |
  240|   845k|    struct mp_frame frame = p->sub.frame;
  241|       |
  242|   845k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (242:9): [True: 32.5k, False: 812k]
  ------------------
  243|  32.5k|        mp_subfilter_continue(&p->sub);
  244|  32.5k|        return;
  245|  32.5k|    }
  246|       |
  247|   812k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (247:9): [True: 0, False: 812k]
  ------------------
  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|   812k|    struct mp_image *img = frame.data;
  253|       |
  254|   812k|    if (img->params.rotate == p->prev_rotate &&
  ------------------
  |  Branch (254:9): [True: 780k, False: 32.5k]
  ------------------
  255|   780k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (255:9): [True: 780k, False: 0]
  ------------------
  256|   780k|    {
  257|   780k|        img->params.rotate = p->target_rotate;
  258|   780k|        mp_subfilter_continue(&p->sub);
  259|   780k|        return;
  260|   780k|    }
  261|       |
  262|  32.5k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (262:9): [True: 0, False: 32.5k]
  ------------------
  263|      0|        return;
  264|       |
  265|  32.5k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (265:5): [True: 32.5k, False: 0]
  ------------------
  266|       |
  267|  32.5k|    int rotate = p->prev_rotate = img->params.rotate;
  268|  32.5k|    p->target_rotate = rotate;
  269|  32.5k|    p->prev_imgfmt = img->imgfmt;
  270|       |
  271|  32.5k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  272|  32.5k|    if (rotate == 0 || (info && info->rotate90 && !(rotate % 90))) {
  ------------------
  |  Branch (272:9): [True: 32.5k, False: 0]
  |  Branch (272:25): [True: 0, False: 0]
  |  Branch (272:33): [True: 0, False: 0]
  |  Branch (272:51): [True: 0, False: 0]
  ------------------
  273|  32.5k|        mp_subfilter_continue(&p->sub);
  274|  32.5k|        return;
  275|  32.5k|    }
  276|       |
  277|      0|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (277:9): [True: 0, False: 0]
  ------------------
  278|      0|        MP_ERR(f, "Video rotation with this format not supported\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  279|      0|        mp_subfilter_continue(&p->sub);
  280|      0|        return;
  281|      0|    }
  282|       |
  283|      0|    double angle = rotate / 360.0 * M_PI * 2;
  284|      0|    char *args[] = {"angle", mp_tprintf(30, "%f", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  285|      0|                    "ow", mp_tprintf(30, "rotw(%f)", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  286|      0|                    "oh", mp_tprintf(30, "roth(%f)", angle),
  ------------------
  |  |  195|      0|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  287|      0|                    NULL};
  288|      0|    p->sub.filter =
  289|      0|        mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "rotate", args);
  290|       |
  291|      0|    if (p->sub.filter) {
  ------------------
  |  Branch (291:9): [True: 0, False: 0]
  ------------------
  292|      0|        MP_INFO(f, "Inserting rotation filter.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  293|      0|        p->target_rotate = 0;
  294|      0|    } else {
  295|      0|        MP_ERR(f, "could not create rotation filter\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  296|      0|    }
  297|       |
  298|      0|    mp_subfilter_continue(&p->sub);
  299|      0|}
f_auto_filters.c:rotate_command:
  317|   845k|{
  318|   845k|    struct rotate_priv *p = f->priv;
  319|       |
  320|   845k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (320:9): [True: 845k, False: 0]
  ------------------
  321|   845k|        cmd->is_active = !!p->sub.filter;
  322|   845k|        return true;
  323|   845k|    }
  324|      0|    return false;
  325|   845k|}
f_auto_filters.c:vflip_destroy:
  430|  32.5k|{
  431|  32.5k|    struct vflip_priv *p = f->priv;
  432|       |
  433|  32.5k|    mp_subfilter_reset(&p->sub);
  434|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  32.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  32.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  435|  32.5k|}
f_auto_filters.c:vflip_process:
  359|  1.72M|{
  360|  1.72M|    struct vflip_priv *p = f->priv;
  361|       |
  362|  1.72M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (362:9): [True: 877k, False: 845k]
  ------------------
  363|   877k|        return;
  364|       |
  365|   845k|    struct mp_frame frame = p->sub.frame;
  366|       |
  367|   845k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (367:9): [True: 32.5k, False: 812k]
  ------------------
  368|  32.5k|        mp_subfilter_continue(&p->sub);
  369|  32.5k|        return;
  370|  32.5k|    }
  371|       |
  372|   812k|    if (frame.type != MP_FRAME_VIDEO) {
  ------------------
  |  Branch (372:9): [True: 0, False: 812k]
  ------------------
  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|   812k|    struct mp_image *img = frame.data;
  378|       |
  379|   812k|    if (img->params.vflip == p->prev_vflip &&
  ------------------
  |  Branch (379:9): [True: 780k, False: 32.5k]
  ------------------
  380|   780k|        img->imgfmt == p->prev_imgfmt)
  ------------------
  |  Branch (380:9): [True: 780k, False: 0]
  ------------------
  381|   780k|    {
  382|   780k|        img->params.vflip = p->target_vflip;
  383|   780k|        mp_subfilter_continue(&p->sub);
  384|   780k|        return;
  385|   780k|    }
  386|       |
  387|  32.5k|    if (!mp_subfilter_drain_destroy(&p->sub))
  ------------------
  |  Branch (387:9): [True: 0, False: 32.5k]
  ------------------
  388|      0|        return;
  389|       |
  390|  32.5k|    mp_assert(!p->sub.filter);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (390:5): [True: 32.5k, False: 0]
  ------------------
  391|       |
  392|  32.5k|    int vflip = p->prev_vflip = img->params.vflip;
  393|  32.5k|    p->target_vflip = vflip;
  394|  32.5k|    p->prev_imgfmt = img->imgfmt;
  395|       |
  396|  32.5k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  397|  32.5k|    if (!vflip || (info && info->vflip)) {
  ------------------
  |  Branch (397:9): [True: 32.5k, False: 0]
  |  Branch (397:20): [True: 0, False: 0]
  |  Branch (397:28): [True: 0, False: 0]
  ------------------
  398|  32.5k|        mp_subfilter_continue(&p->sub);
  399|  32.5k|        return;
  400|  32.5k|    }
  401|       |
  402|      0|    if (!mp_sws_supports_input(img->imgfmt)) {
  ------------------
  |  Branch (402:9): [True: 0, False: 0]
  ------------------
  403|      0|        MP_ERR(f, "Video vflip with this format not supported\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  404|      0|        mp_subfilter_continue(&p->sub);
  405|      0|        return;
  406|      0|    }
  407|       |
  408|      0|    char *args[] = {NULL};
  409|       |
  410|      0|    p->sub.filter = mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "vflip", args);
  411|       |
  412|      0|    if (p->sub.filter) {
  ------------------
  |  Branch (412:9): [True: 0, False: 0]
  ------------------
  413|      0|        MP_INFO(f, "Inserting vflip filter.\n");
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  414|      0|        p->target_vflip = 0;
  415|      0|    } else {
  416|      0|        MP_ERR(f, "could not create vflip filter\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  417|      0|    }
  418|       |
  419|      0|    mp_subfilter_continue(&p->sub);
  420|      0|}
f_auto_filters.c:vflip_command:
  438|   845k|{
  439|   845k|    struct vflip_priv *p = f->priv;
  440|       |
  441|   845k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (441:9): [True: 845k, False: 0]
  ------------------
  442|   845k|        cmd->is_active = !!p->sub.filter;
  443|   845k|        return true;
  444|   845k|    }
  445|      0|    return false;
  446|   845k|}

mp_autoconvert_clear:
   61|  97.5k|{
   62|  97.5k|    struct priv *p = c->f->priv;
   63|       |
   64|  97.5k|    p->num_imgfmts = 0;
   65|  97.5k|    p->imgparams_set = false;
   66|  97.5k|    p->num_afmts = 0;
   67|  97.5k|    p->num_srates = 0;
   68|  97.5k|    p->chmaps = (struct mp_chmap_sel){0};
   69|       |    p->force_update = true;
   70|  97.5k|}
mp_autoconvert_add_imgfmt:
   73|  54.5M|{
   74|  54.5M|    struct priv *p = c->f->priv;
   75|       |
   76|  54.5M|    MP_TARRAY_GROW(p, p->imgfmts, p->num_imgfmts);
  ------------------
  |  |   96|  54.5M|    do {                                            \
  |  |   97|  54.5M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  54.5M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  54.5M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  54.5M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 292k, False: 54.2M]
  |  |  ------------------
  |  |   99|  54.5M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   292k|    do {                                                        \
  |  |  |  |   89|   292k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   292k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   292k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   292k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   292k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   292k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   292k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 292k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  54.5M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 54.5M]
  |  |  ------------------
  ------------------
   77|  54.5M|    MP_TARRAY_GROW(p, p->subfmts, p->num_imgfmts);
  ------------------
  |  |   96|  54.5M|    do {                                            \
  |  |   97|  54.5M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  54.5M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  54.5M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  54.5M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 292k, False: 54.2M]
  |  |  ------------------
  |  |   99|  54.5M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   292k|    do {                                                        \
  |  |  |  |   89|   292k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   292k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   292k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   292k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   292k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   292k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   292k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 292k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  54.5M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 54.5M]
  |  |  ------------------
  ------------------
   78|       |
   79|  54.5M|    p->imgfmts[p->num_imgfmts] = imgfmt;
   80|  54.5M|    p->subfmts[p->num_imgfmts] = subfmt;
   81|       |
   82|  54.5M|    p->num_imgfmts += 1;
   83|       |    p->force_update = true;
   84|  54.5M|}
mp_autoconvert_create:
  566|  32.5k|{
  567|  32.5k|    struct mp_filter *f = mp_filter_create(parent, &autoconvert_filter);
  568|  32.5k|    if (!f)
  ------------------
  |  Branch (568:9): [True: 0, False: 32.5k]
  ------------------
  569|      0|        return NULL;
  570|       |
  571|  32.5k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  572|  32.5k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  573|       |
  574|  32.5k|    struct priv *p = f->priv;
  575|  32.5k|    p->public.f = f;
  576|  32.5k|    p->log = f->log;
  577|  32.5k|    p->audio_speed = 1.0;
  578|  32.5k|    p->sub.in = f->ppins[0];
  579|  32.5k|    p->sub.out = f->ppins[1];
  580|       |
  581|  32.5k|    return &p->public;
  582|  32.5k|}
f_autoconvert.c:build_image_converter:
  141|  32.5k|{
  142|  32.5k|    struct mp_filter *f = c->f;
  143|  32.5k|    struct priv *p = f->priv;
  144|       |
  145|  32.5k|    *f_out = NULL;
  146|       |
  147|  32.5k|    if (!p->num_imgfmts)
  ------------------
  |  Branch (147:9): [True: 0, False: 32.5k]
  ------------------
  148|      0|        return true;
  149|       |
  150|  65.0k|    for (int n = 0; n < p->num_imgfmts; n++) {
  ------------------
  |  Branch (150:21): [True: 65.0k, False: 0]
  ------------------
  151|  65.0k|        bool samefmt = img->params.imgfmt == p->imgfmts[n];
  152|  65.0k|        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|  65.0k|        if (samefmt && samesubffmt) {
  ------------------
  |  Branch (158:13): [True: 32.5k, False: 32.5k]
  |  Branch (158:24): [True: 32.5k, False: 0]
  ------------------
  159|  32.5k|            if (p->imgparams_set) {
  ------------------
  |  Branch (159:17): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|            return true;
  164|  32.5k|        }
  165|  65.0k|    }
  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|  32.5k|{
  550|  32.5k|    struct priv *p = f->priv;
  551|       |
  552|  32.5k|    mp_subfilter_reset(&p->sub);
  553|       |    TA_FREEP(&p->sub.filter);
  ------------------
  |  |   81|  32.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  32.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  554|  32.5k|}
f_autoconvert.c:autoconvert_process:
  487|  1.72M|{
  488|  1.72M|    struct priv *p = f->priv;
  489|       |
  490|  1.72M|    if (!mp_subfilter_read(&p->sub))
  ------------------
  |  Branch (490:9): [True: 877k, False: 845k]
  ------------------
  491|   877k|        return;
  492|       |
  493|   845k|    if (p->sub.frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (493:9): [True: 812k, False: 32.5k]
  ------------------
  494|   812k|        handle_video_frame(f);
  495|   812k|        return;
  496|   812k|    }
  497|       |
  498|  32.5k|    if (p->sub.frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (498:9): [True: 0, False: 32.5k]
  ------------------
  499|      0|        handle_audio_frame(f);
  500|      0|        return;
  501|      0|    }
  502|       |
  503|  32.5k|    mp_subfilter_continue(&p->sub);
  504|  32.5k|}
f_autoconvert.c:handle_video_frame:
  350|   812k|{
  351|   812k|    struct priv *p = f->priv;
  352|       |
  353|   812k|    struct mp_image *img = p->sub.frame.data;
  354|       |
  355|   812k|    if (p->force_update)
  ------------------
  |  Branch (355:9): [True: 32.5k, False: 780k]
  ------------------
  356|  32.5k|        p->in_imgfmt = p->in_subfmt = 0;
  357|       |
  358|   812k|    if (img->imgfmt == p->in_imgfmt && img->params.hw_subfmt == p->in_subfmt) {
  ------------------
  |  Branch (358:9): [True: 780k, False: 32.5k]
  |  Branch (358:40): [True: 780k, False: 0]
  ------------------
  359|   780k|        mp_subfilter_continue(&p->sub);
  360|   780k|        return;
  361|   780k|    }
  362|       |
  363|  32.5k|    if (!mp_subfilter_drain_destroy(&p->sub)) {
  ------------------
  |  Branch (363:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    p->in_imgfmt = img->params.imgfmt;
  369|  32.5k|    p->in_subfmt = img->params.hw_subfmt;
  370|  32.5k|    p->force_update = false;
  371|       |
  372|  32.5k|    struct mp_filter *conv = NULL;
  373|  32.5k|    if (build_image_converter(&p->public, p->log, img, &conv)) {
  ------------------
  |  Branch (373:9): [True: 32.5k, False: 0]
  ------------------
  374|  32.5k|        p->sub.filter = conv;
  375|  32.5k|        mp_subfilter_continue(&p->sub);
  376|  32.5k|    } else {
  377|      0|        mp_filter_internal_mark_failed(f);
  378|      0|    }
  379|  32.5k|}
f_autoconvert.c:autoconvert_command:
  518|   845k|{
  519|   845k|    struct priv *p = f->priv;
  520|       |
  521|   845k|    if (cmd->type == MP_FILTER_COMMAND_SET_SPEED_RESAMPLE) {
  ------------------
  |  Branch (521:9): [True: 0, False: 845k]
  ------------------
  522|      0|        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|      0|        if (p->audio_speed != 1.0)
  ------------------
  |  Branch (525:13): [True: 0, False: 0]
  ------------------
  526|      0|            p->resampling_forced = true;
  527|      0|        return true;
  528|      0|    }
  529|       |
  530|   845k|    if (cmd->type == MP_FILTER_COMMAND_IS_ACTIVE) {
  ------------------
  |  Branch (530:9): [True: 845k, False: 0]
  ------------------
  531|   845k|        cmd->is_active = !!p->sub.filter;
  532|   845k|        return true;
  533|   845k|    }
  534|       |
  535|      0|    return false;
  536|   845k|}

mp_decoder_wrapper_control:
  363|  32.6k|{
  364|  32.6k|    struct priv *p = d->f->priv;
  365|  32.6k|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  32.6k|#define CONTROL_UNKNOWN -1
  ------------------
  366|  32.6k|    if (p->is_group) {
  ------------------
  |  Branch (366:9): [True: 0, False: 32.6k]
  ------------------
  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|  32.6k|    thread_lock(p);
  379|  32.6k|    if (cmd == VDCTRL_GET_HWDEC) {
  ------------------
  |  Branch (379:9): [True: 0, False: 32.6k]
  ------------------
  380|      0|        res = update_cached_values(p);
  381|      0|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  382|      0|        *(char **)arg = p->cur_hwdec;
  383|      0|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  384|  32.6k|    } else {
  385|  32.6k|        if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (385:13): [True: 32.6k, False: 0]
  |  Branch (385:27): [True: 32.6k, False: 0]
  ------------------
  386|  32.6k|            res = p->decoder->control(p->decoder->f, cmd, arg);
  387|  32.6k|        update_cached_values(p);
  388|  32.6k|    }
  389|  32.6k|    thread_unlock(p);
  390|  32.6k|    return res;
  391|  32.6k|}
mp_decoder_wrapper_reinit:
  532|  32.5k|{
  533|  32.5k|    struct priv *p = d->f->priv;
  534|  32.5k|    if (p->is_group) {
  ------------------
  |  Branch (534:9): [True: 0, False: 32.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|  32.5k|    thread_lock(p);
  542|       |    bool res = reinit_decoder(p);
  543|  32.5k|    thread_unlock(p);
  544|  32.5k|    return res;
  545|  32.5k|}
mp_decoder_wrapper_get_container_fps:
  578|  32.5k|{
  579|  32.5k|    struct priv *p = d->f->priv;
  580|  32.5k|    thread_lock(p);
  581|  32.5k|    double res = p->fps;
  582|  32.5k|    thread_unlock(p);
  583|  32.5k|    return res;
  584|  32.5k|}
mp_decoder_wrapper_set_play_dir:
  612|  65.0k|{
  613|  65.0k|    struct priv *p = d->f->priv;
  614|  65.0k|    if (p->is_group) {
  ------------------
  |  Branch (614:9): [True: 0, False: 65.0k]
  ------------------
  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|  65.0k|    thread_lock(p);
  621|  65.0k|    p->play_dir = dir;
  622|  65.0k|    thread_unlock(p);
  623|  65.0k|}
mp_decoder_wrapper_create:
 1378|  32.5k|{
 1379|  32.5k|    struct mp_filter *public_f = mp_filter_create(parent, &decode_wrapper_filter);
 1380|  32.5k|    if (!public_f)
  ------------------
  |  Branch (1380:9): [True: 0, False: 32.5k]
  ------------------
 1381|      0|        return NULL;
 1382|       |
 1383|  32.5k|    struct priv *p = public_f->priv;
 1384|  32.5k|    p->public.f = public_f;
 1385|       |
 1386|  32.5k|    mp_mutex_init(&p->cache_lock);
 1387|  32.5k|    p->opt_cache = m_config_cache_alloc(p, public_f->global, &dec_wrapper_conf);
 1388|  32.5k|    p->opts = p->opt_cache->opts;
 1389|  32.5k|    p->header = src;
 1390|  32.5k|    p->codec = p->header->codec;
 1391|  32.5k|    p->play_dir = 1;
 1392|  32.5k|    mp_filter_add_pin(public_f, MP_PIN_OUT, "out");
 1393|       |
 1394|  32.5k|    if (src->group && src->group->lavfi_graph) {
  ------------------
  |  Branch (1394:9): [True: 0, False: 32.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|  32.5k|    if (p->header->type == STREAM_VIDEO) {
  ------------------
  |  Branch (1404:9): [True: 32.5k, False: 0]
  ------------------
 1405|  32.5k|        p->log = mp_log_new(p, parent->global->log, "!vd");
 1406|       |
 1407|  32.5k|        p->fps = src->codec->fps;
 1408|       |
 1409|  32.5k|        MP_VERBOSE(p, "Container reported FPS: %f\n", p->fps);
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1410|       |
 1411|  32.5k|        if (p->opts->fps_override) {
  ------------------
  |  Branch (1411:13): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|        p->queue_opts = p->opts->vdec_queue_opts;
 1418|  32.5k|    } else if (p->header->type == STREAM_AUDIO) {
  ------------------
  |  Branch (1418:16): [True: 0, False: 0]
  ------------------
 1419|      0|        p->log = mp_log_new(p, parent->global->log, "!ad");
 1420|      0|        p->queue_opts = p->opts->adec_queue_opts;
 1421|      0|    } else {
 1422|      0|        goto error;
 1423|      0|    }
 1424|       |
 1425|  32.5k|    if (p->queue_opts && p->queue_opts->use_queue) {
  ------------------
  |  Branch (1425:9): [True: 32.5k, False: 0]
  |  Branch (1425:26): [True: 0, False: 32.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|  32.5k|    p->decf = mp_filter_create(p->dec_root_filter ? p->dec_root_filter : public_f,
  ------------------
  |  Branch (1444:32): [True: 0, False: 32.5k]
  ------------------
 1445|  32.5k|                               &decf_filter);
 1446|  32.5k|    if (!p->decf)
  ------------------
  |  Branch (1446:9): [True: 0, False: 32.5k]
  ------------------
 1447|      0|        goto error;
 1448|  32.5k|    p->decf->priv = p;
 1449|  32.5k|    p->decf->log = public_f->log = p->log;
 1450|  32.5k|    mp_filter_add_pin(p->decf, MP_PIN_OUT, "out");
 1451|       |
 1452|  32.5k|    struct mp_filter *demux = mp_demux_in_create(p->decf, p->header);
 1453|  32.5k|    if (!demux)
  ------------------
  |  Branch (1453:9): [True: 0, False: 32.5k]
  ------------------
 1454|      0|        goto error;
 1455|  32.5k|    p->demux = demux->pins[0];
 1456|       |
 1457|  32.5k|    decf_reset(p->decf);
 1458|       |
 1459|  32.5k|    struct mp_pin *out_pin;
 1460|  32.5k|    if (p->queue) {
  ------------------
  |  Branch (1460:9): [True: 0, False: 32.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|  32.5k|    } else {
 1474|  32.5k|        out_pin = p->decf->pins[0];
 1475|  32.5k|    }
 1476|       |
 1477|  32.5k|    mp_pin_connect(public_f->ppins[0], out_pin);
 1478|       |
 1479|  32.5k|    public_f_reset(public_f);
 1480|       |
 1481|  32.5k|    return &p->public;
 1482|      0|error:
 1483|      0|    talloc_free(public_f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1484|       |    return NULL;
 1485|  32.5k|}
lavc_process:
 1490|  2.56M|{
 1491|  2.56M|    if (!mp_pin_in_needs_data(f->ppins[1]))
  ------------------
  |  Branch (1491:9): [True: 32.5k, False: 2.53M]
  ------------------
 1492|  32.5k|        return;
 1493|       |
 1494|  2.53M|    struct mp_frame frame = {0};
 1495|  2.53M|    int ret_recv = receive(f, &frame);
 1496|  2.53M|    if (frame.type) {
  ------------------
  |  Branch (1496:9): [True: 812k, False: 1.72M]
  ------------------
 1497|   812k|        state->eof_returned = false;
 1498|   812k|        mp_pin_in_write(f->ppins[1], frame);
 1499|  1.72M|    } else if (ret_recv == AVERROR_EOF) {
  ------------------
  |  Branch (1499:16): [True: 32.5k, False: 1.69M]
  ------------------
 1500|  32.5k|        if (!state->eof_returned)
  ------------------
  |  Branch (1500:13): [True: 32.5k, False: 0]
  ------------------
 1501|  32.5k|            mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|  32.5k|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|  32.5k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1502|  32.5k|        state->eof_returned = true;
 1503|  32.5k|        state->packets_sent = false;
 1504|  1.69M|    } else if (ret_recv == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1504:16): [True: 1.69M, False: 0]
  ------------------
 1505|       |        // Need to feed a packet.
 1506|  1.69M|        frame = mp_pin_out_read(f->ppins[0]);
 1507|  1.69M|        struct demux_packet *pkt = NULL;
 1508|  1.69M|        if (frame.type == MP_FRAME_PACKET) {
  ------------------
  |  Branch (1508:13): [True: 812k, False: 877k]
  ------------------
 1509|   812k|            pkt = frame.data;
 1510|   877k|        } else if (frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1510:20): [True: 845k, False: 32.5k]
  ------------------
 1511|   845k|            if (frame.type) {
  ------------------
  |  Branch (1511:17): [True: 0, False: 845k]
  ------------------
 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|   845k|            return;
 1517|   845k|        } else if (!state->packets_sent) {
  ------------------
  |  Branch (1517:20): [True: 0, False: 32.5k]
  ------------------
 1518|       |            // EOF only; just return it, without requiring send/receive to
 1519|       |            // pass it through properly.
 1520|      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)})
  |  |  ------------------
  ------------------
 1521|      0|            return;
 1522|      0|        }
 1523|   845k|        int ret_send = send(f, pkt);
 1524|   845k|        if (ret_send == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1524:13): [True: 0, False: 845k]
  ------------------
 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|   845k|        state->packets_sent = true;
 1532|   845k|        demux_packet_pool_push(f->packet_pool, pkt);
 1533|   845k|        mp_filter_internal_mark_progress(f);
 1534|   845k|    } else {
 1535|       |        // Decoding error, or hwdec fallback recovery. Just try again.
 1536|      0|        mp_filter_internal_mark_progress(f);
 1537|      0|    }
 1538|  2.53M|}
f_decoder_wrapper.c:thread_lock:
  292|   162k|{
  293|   162k|    if (p->dec_dispatch)
  ------------------
  |  Branch (293:9): [True: 0, False: 162k]
  ------------------
  294|      0|        mp_dispatch_lock(p->dec_dispatch);
  295|       |
  296|   162k|    mp_assert(!p->dec_thread_lock);
  ------------------
  |  |   41|   162k|#define mp_assert assert
  ------------------
  |  Branch (296:5): [True: 162k, False: 0]
  ------------------
  297|   162k|    p->dec_thread_lock = true;
  298|   162k|}
f_decoder_wrapper.c:update_cached_values:
  275|  65.1k|{
  276|  65.1k|    int res = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  65.1k|#define CONTROL_UNKNOWN -1
  ------------------
  277|  65.1k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  65.1k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  278|       |
  279|  65.1k|    p->cur_hwdec = NULL;
  280|  65.1k|    if (p->decoder && p->decoder->control)
  ------------------
  |  Branch (280:9): [True: 65.1k, False: 0]
  |  Branch (280:23): [True: 65.1k, False: 0]
  ------------------
  281|  65.1k|        res = p->decoder->control(p->decoder->f, VDCTRL_GET_HWDEC, &p->cur_hwdec);
  282|       |
  283|  65.1k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  65.1k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  284|  65.1k|    return res;
  285|  65.1k|}
f_decoder_wrapper.c:thread_unlock:
  302|   162k|{
  303|   162k|    mp_assert(p->dec_thread_lock);
  ------------------
  |  |   41|   162k|#define mp_assert assert
  ------------------
  |  Branch (303:5): [True: 162k, False: 0]
  ------------------
  304|   162k|    p->dec_thread_lock = false;
  305|       |
  306|   162k|    if (p->dec_dispatch)
  ------------------
  |  Branch (306:9): [True: 0, False: 162k]
  ------------------
  307|      0|        mp_dispatch_unlock(p->dec_dispatch);
  308|   162k|}
f_decoder_wrapper.c:reinit_decoder:
  425|  32.5k|{
  426|  32.5k|    if (p->decoder)
  ------------------
  |  Branch (426:9): [True: 0, False: 32.5k]
  ------------------
  427|      0|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  428|  32.5k|    p->decoder = NULL;
  429|       |
  430|  32.5k|    reset_decoder(p);
  431|  32.5k|    p->has_broken_packet_pts = -10; // needs 10 packets to reach decision
  432|       |
  433|  32.5k|    const struct mp_decoder_fns *driver = NULL;
  434|  32.5k|    struct mp_decoder_list *list = NULL;
  435|  32.5k|    char *user_list = NULL;
  436|  32.5k|    char *fallback = NULL;
  437|       |
  438|  32.5k|    if (p->codec->type == STREAM_VIDEO) {
  ------------------
  |  Branch (438:9): [True: 32.5k, False: 0]
  ------------------
  439|  32.5k|        driver = &vd_lavc;
  440|  32.5k|        user_list = p->opts->video_decoders;
  441|  32.5k|        fallback = "h264";
  442|  32.5k|    } else if (p->codec->type == STREAM_AUDIO) {
  ------------------
  |  Branch (442:16): [True: 0, False: 0]
  ------------------
  443|      0|        driver = &ad_lavc;
  444|      0|        user_list = p->opts->audio_decoders;
  445|      0|        fallback = "aac";
  446|       |
  447|      0|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|      0|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  448|      0|        bool try_spdif = p->try_spdif;
  449|      0|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|      0|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  450|       |
  451|      0|        if (try_spdif && p->codec->codec) {
  ------------------
  |  Branch (451:13): [True: 0, False: 0]
  |  Branch (451:26): [True: 0, False: 0]
  ------------------
  452|      0|            struct mp_decoder_list *spdif =
  453|      0|                select_spdif_codec(p->codec->codec, p->opts->audio_spdif);
  454|      0|            if (spdif->num_entries) {
  ------------------
  |  Branch (454:17): [True: 0, False: 0]
  ------------------
  455|      0|                driver = &ad_spdif;
  456|      0|                list = spdif;
  457|      0|            } else {
  458|      0|                talloc_free(spdif);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  459|      0|                struct mp_decoder_list *dsd =
  460|      0|                    select_dsd_codec(p->codec->codec, p->opts->audio_spdif);
  461|      0|                if (dsd->num_entries) {
  ------------------
  |  Branch (461:21): [True: 0, False: 0]
  ------------------
  462|      0|                    driver = &ad_dsd;
  463|      0|                    list = dsd;
  464|      0|                } else {
  465|      0|                    talloc_free(dsd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  466|      0|                }
  467|      0|            }
  468|      0|        }
  469|      0|    }
  470|       |
  471|  32.5k|    if (!driver)
  ------------------
  |  Branch (471:9): [True: 0, False: 32.5k]
  ------------------
  472|      0|        return false;
  473|       |
  474|  32.5k|    if (!list) {
  ------------------
  |  Branch (474:9): [True: 32.5k, False: 0]
  ------------------
  475|  32.5k|        struct mp_decoder_list *full = talloc_zero(NULL, struct mp_decoder_list);
  ------------------
  |  |   27|  32.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  32.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|  32.5k|        driver->add_decoders(full);
  477|  32.5k|        const char *codec = p->codec->codec;
  478|  32.5k|        if (codec && strcmp(codec, "null") == 0)
  ------------------
  |  Branch (478:13): [True: 32.5k, False: 0]
  |  Branch (478:22): [True: 0, False: 32.5k]
  ------------------
  479|      0|            codec = fallback;
  480|  32.5k|        list = mp_select_decoders(p->log, full, codec, user_list);
  481|  32.5k|        talloc_free(full);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  482|  32.5k|    }
  483|       |
  484|  32.5k|    mp_print_decoders(p->log, MSGL_V, "Codec list:", list);
  485|       |
  486|  32.5k|    for (int n = 0; n < list->num_entries; n++) {
  ------------------
  |  Branch (486:21): [True: 32.5k, False: 0]
  ------------------
  487|  32.5k|        struct mp_decoder_entry *sel = &list->entries[n];
  488|  32.5k|        MP_VERBOSE(p, "Opening decoder %s\n", sel->decoder);
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  489|       |
  490|  32.5k|        p->decoder = driver->create(p->decf, p->codec, sel->decoder);
  491|  32.5k|        if (p->decoder) {
  ------------------
  |  Branch (491:13): [True: 32.5k, False: 0]
  ------------------
  492|  32.5k|            p->codec->decoder = talloc_strdup(p->codec, sel->decoder);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  493|  32.5k|            p->codec->decoder_desc = talloc_strdup(p->codec, sel->desc && sel->desc[0] ? sel->desc : NULL);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (493:62): [True: 32.5k, False: 0]
  |  Branch (493:75): [True: 32.5k, False: 0]
  ------------------
  494|  32.5k|            MP_VERBOSE(p, "Selected decoder: %s", sel->decoder);
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  495|  32.5k|            if (p->codec->decoder_desc)
  ------------------
  |  Branch (495:17): [True: 32.5k, False: 0]
  ------------------
  496|  32.5k|                MP_VERBOSE(p, " - %s", p->codec->decoder_desc);
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  497|  32.5k|            MP_VERBOSE(p, "\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  498|  32.5k|            break;
  499|  32.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|  32.5k|    if (!p->decoder) {
  ------------------
  |  Branch (504:9): [True: 0, False: 32.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|  32.5k|    if (p->decoder && p->decoder->control) {
  ------------------
  |  Branch (509:9): [True: 32.5k, False: 0]
  |  Branch (509:23): [True: 32.5k, False: 0]
  ------------------
  510|  32.5k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  32.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  511|  32.5k|        int extra_hw_frames = p->extra_hw_frames;
  512|  32.5k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  32.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  513|  32.5k|        if (extra_hw_frames > 0) {
  ------------------
  |  Branch (513:13): [True: 0, False: 32.5k]
  ------------------
  514|      0|            p->decoder->control(p->decoder->f, VDCTRL_SET_EXTRA_HW_FRAMES,
  515|      0|                                &extra_hw_frames);
  516|      0|        }
  517|  32.5k|    }
  518|       |
  519|  32.5k|    update_cached_values(p);
  520|       |
  521|  32.5k|    talloc_free(list);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  522|  32.5k|    return !!p->decoder;
  523|  32.5k|}
f_decoder_wrapper.c:reset_decoder:
  315|  97.5k|{
  316|  97.5k|    p->first_packet_pdts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  97.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  317|  97.5k|    p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  97.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  318|  97.5k|    p->codec_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  97.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  319|  97.5k|    p->codec_dts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  97.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  320|  97.5k|    p->num_codec_pts_problems = 0;
  321|  97.5k|    p->num_codec_dts_problems = 0;
  322|  97.5k|    p->has_broken_decoded_pts = 0;
  323|  97.5k|    p->packets_without_output = 0;
  324|  97.5k|    mp_frame_unref(&p->packet);
  325|  97.5k|    p->packet_fed = false;
  326|  97.5k|    p->preroll_discard = false;
  327|  97.5k|    talloc_free(p->new_segment);
  ------------------
  |  |   47|  97.5k|#define talloc_free                     ta_free
  ------------------
  328|  97.5k|    p->new_segment = NULL;
  329|  97.5k|    p->start = p->end = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  97.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  330|       |
  331|  97.5k|    if (p->decoder)
  ------------------
  |  Branch (331:9): [True: 0, False: 97.5k]
  ------------------
  332|      0|        mp_filter_reset(p->decoder->f);
  333|  97.5k|}
f_decoder_wrapper.c:public_f_destroy:
 1252|  32.5k|{
 1253|  32.5k|    struct priv *p = f->priv;
 1254|  32.5k|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1254:5): [True: 32.5k, False: 0]
  ------------------
 1255|       |
 1256|  32.5k|    if (p->dec_thread_valid) {
  ------------------
  |  Branch (1256:9): [True: 0, False: 32.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|  32.5k|    mp_filter_free_children(f);
 1267|       |
 1268|  32.5k|    talloc_free(p->dec_root_filter);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1269|  32.5k|    talloc_free(p->queue);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1270|  32.5k|    mp_mutex_destroy(&p->cache_lock);
  ------------------
  |  |  133|  32.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1271|  32.5k|}
f_decoder_wrapper.c:public_f_reset:
 1237|  32.5k|{
 1238|  32.5k|    struct priv *p = f->priv;
 1239|  32.5k|    mp_assert(p->public.f == f);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1239:5): [True: 32.5k, False: 0]
  ------------------
 1240|       |
 1241|  32.5k|    if (p->queue) {
  ------------------
  |  Branch (1241:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|}
f_decoder_wrapper.c:decf_destroy:
  394|  32.5k|{
  395|  32.5k|    struct priv *p = f->priv;
  396|  32.5k|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 32.5k, False: 0]
  ------------------
  397|       |
  398|  32.5k|    if (p->decoder) {
  ------------------
  |  Branch (398:9): [True: 32.5k, False: 0]
  ------------------
  399|  32.5k|        MP_DBG(f, "Uninit decoder.\n");
  ------------------
  |  |   93|  32.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  400|  32.5k|        talloc_free(p->decoder->f);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  401|  32.5k|        p->decoder = NULL;
  402|  32.5k|        p->codec->decoder = NULL;
  403|  32.5k|        p->codec->decoder_desc = NULL;
  404|  32.5k|    }
  405|       |
  406|  32.5k|    decf_reset(f);
  407|  32.5k|    mp_frame_unref(&p->decoded_coverart);
  408|  32.5k|}
f_decoder_wrapper.c:decf_process:
 1205|  3.41M|{
 1206|  3.41M|    struct priv *p = f->priv;
 1207|  3.41M|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  3.41M|#define mp_assert assert
  ------------------
  |  Branch (1207:5): [True: 3.41M, False: 0]
  ------------------
 1208|       |
 1209|  3.41M|    if (m_config_cache_update(p->opt_cache))
  ------------------
  |  Branch (1209:9): [True: 0, False: 3.41M]
  ------------------
 1210|      0|        update_queue_config(p);
 1211|       |
 1212|  3.41M|    feed_packet(p);
 1213|  3.41M|    read_frame(p);
 1214|  3.41M|}
f_decoder_wrapper.c:feed_packet:
  967|  3.41M|{
  968|  3.41M|    if (!p->decoder || !mp_pin_in_needs_data(p->decoder->f->pins[0]))
  ------------------
  |  Branch (968:9): [True: 0, False: 3.41M]
  |  Branch (968:24): [True: 1.72M, False: 1.69M]
  ------------------
  969|  1.72M|        return;
  970|       |
  971|  1.69M|    if (p->decoded_coverart.type)
  ------------------
  |  Branch (971:9): [True: 0, False: 1.69M]
  ------------------
  972|      0|        return;
  973|       |
  974|       |    // Don't read after EOF was output. If the stream continues, the player
  975|       |    // creates a new decoder.
  976|  1.69M|    if (p->eof_output)
  ------------------
  |  Branch (976:9): [True: 0, False: 1.69M]
  ------------------
  977|      0|        return;
  978|       |
  979|  1.69M|    if (!p->packet.type && !p->new_segment) {
  ------------------
  |  Branch (979:9): [True: 1.69M, False: 0]
  |  Branch (979:28): [True: 1.69M, False: 0]
  ------------------
  980|  1.69M|        p->packet = mp_pin_out_read(p->demux);
  981|  1.69M|        if (!p->packet.type)
  ------------------
  |  Branch (981:13): [True: 845k, False: 845k]
  ------------------
  982|   845k|            return;
  983|   845k|        if (p->packet.type != MP_FRAME_EOF && p->packet.type != MP_FRAME_PACKET) {
  ------------------
  |  Branch (983:13): [True: 812k, False: 32.5k]
  |  Branch (983:47): [True: 0, False: 812k]
  ------------------
  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|   845k|    }
  990|       |
  991|   845k|    if (!p->packet.type)
  ------------------
  |  Branch (991:9): [True: 0, False: 845k]
  ------------------
  992|      0|        return;
  993|       |
  994|       |    // Flush current data if the packet is a new segment.
  995|   845k|    if (is_new_segment(p, p->packet)) {
  ------------------
  |  Branch (995:9): [True: 0, False: 845k]
  ------------------
  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|   845k|    mp_assert(p->packet.type == MP_FRAME_PACKET || p->packet.type == MP_FRAME_EOF);
  ------------------
  |  |   41|   845k|#define mp_assert assert
  ------------------
  |  Branch (1001:5): [True: 812k, False: 32.5k]
  |  Branch (1001:5): [True: 32.5k, False: 0]
  ------------------
 1002|   845k|    struct demux_packet *packet =
 1003|   845k|        p->packet.type == MP_FRAME_PACKET ? p->packet.data : NULL;
  ------------------
  |  Branch (1003:9): [True: 812k, False: 32.5k]
  ------------------
 1004|       |
 1005|       |    // For video framedropping, including parts of the hr-seek logic.
 1006|   845k|    if (p->decoder->control) {
  ------------------
  |  Branch (1006:9): [True: 845k, False: 0]
  ------------------
 1007|   845k|        double start_pts = p->start_pts;
 1008|   845k|        if (p->start != MP_NOPTS_VALUE && (start_pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|  1.69M|#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: 845k]
  |  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|   845k|        int framedrop_type = 0;
 1013|       |
 1014|   845k|        mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|   845k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1015|   845k|        if (p->attempt_framedrops)
  ------------------
  |  Branch (1015:13): [True: 0, False: 845k]
  ------------------
 1016|      0|            framedrop_type = 1;
 1017|   845k|        mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|   845k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1018|       |
 1019|   845k|        if (start_pts != MP_NOPTS_VALUE && packet && p->play_dir > 0 &&
  ------------------
  |  |   39|  1.69M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1019:13): [True: 0, False: 845k]
  |  Branch (1019:44): [True: 0, False: 0]
  |  Branch (1019:54): [True: 0, False: 0]
  ------------------
 1020|      0|            packet->pts < start_pts - .005 && !p->has_broken_packet_pts)
  ------------------
  |  Branch (1020:13): [True: 0, False: 0]
  |  Branch (1020:47): [True: 0, False: 0]
  ------------------
 1021|      0|            framedrop_type = 2;
 1022|       |
 1023|   845k|        p->decoder->control(p->decoder->f, VDCTRL_SET_FRAMEDROP, &framedrop_type);
 1024|   845k|    }
 1025|       |
 1026|   845k|    if (!p->dec_dispatch && p->public.recorder_sink)
  ------------------
  |  Branch (1026:9): [True: 845k, False: 0]
  |  Branch (1026:29): [True: 0, False: 845k]
  ------------------
 1027|      0|        mp_recorder_feed_packet(p->public.recorder_sink, packet);
 1028|       |
 1029|   845k|    double pkt_pts = packet ? packet->pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  32.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1029:22): [True: 812k, False: 32.5k]
  ------------------
 1030|   845k|    double pkt_dts = packet ? packet->dts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  32.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1030:22): [True: 812k, False: 32.5k]
  ------------------
 1031|       |
 1032|   845k|    if (pkt_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   845k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1032:9): [True: 32.5k, False: 812k]
  ------------------
 1033|  32.5k|        p->has_broken_packet_pts = 1;
 1034|       |
 1035|   845k|    if (packet && packet->dts == MP_NOPTS_VALUE && !p->codec->avi_dts)
  ------------------
  |  |   39|  1.65M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1035:9): [True: 812k, False: 32.5k]
  |  Branch (1035:19): [True: 0, False: 812k]
  |  Branch (1035:52): [True: 0, False: 0]
  ------------------
 1036|      0|        packet->dts = packet->pts;
 1037|       |
 1038|   845k|    double pkt_pdts = pkt_pts == MP_NOPTS_VALUE ? pkt_dts : pkt_pts;
  ------------------
  |  |   39|   845k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1038:23): [True: 32.5k, False: 812k]
  ------------------
 1039|   845k|    if (p->first_packet_pdts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   845k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1039:9): [True: 32.5k, False: 812k]
  ------------------
 1040|  32.5k|        p->first_packet_pdts = pkt_pdts;
 1041|       |
 1042|   845k|    if (packet && packet->back_preroll) {
  ------------------
  |  Branch (1042:9): [True: 812k, False: 32.5k]
  |  Branch (1042:19): [True: 0, False: 812k]
  ------------------
 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|   845k|    mp_pin_in_write(p->decoder->f->pins[0], p->packet);
 1048|   845k|    p->packet_fed = true;
 1049|   845k|    p->packet = MP_NO_FRAME;
  ------------------
  |  |   58|   845k|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|   845k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1050|       |
 1051|   845k|    p->packets_without_output += 1;
 1052|   845k|}
f_decoder_wrapper.c:is_new_segment:
  957|   845k|{
  958|   845k|    if (frame.type != MP_FRAME_PACKET)
  ------------------
  |  Branch (958:9): [True: 32.5k, False: 812k]
  ------------------
  959|  32.5k|        return false;
  960|   812k|    struct demux_packet *pkt = frame.data;
  961|   812k|    return (pkt->segmented && (pkt->start != p->start || pkt->end != p->end ||
  ------------------
  |  Branch (961:13): [True: 0, False: 812k]
  |  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|   812k|           (p->play_dir < 0 && pkt->back_restart && p->packet_fed);
  ------------------
  |  Branch (963:13): [True: 0, False: 812k]
  |  Branch (963:32): [True: 0, False: 0]
  |  Branch (963:53): [True: 0, False: 0]
  ------------------
  964|   845k|}
f_decoder_wrapper.c:read_frame:
 1084|  3.41M|{
 1085|  3.41M|    struct mp_pin *pin = p->decf->ppins[0];
 1086|  3.41M|    struct mp_frame frame = {0};
 1087|       |
 1088|  3.41M|    if (!p->decoder) {
  ------------------
  |  Branch (1088:9): [True: 0, False: 3.41M]
  ------------------
 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|  3.41M|    if (!mp_pin_in_needs_data(pin))
  ------------------
  |  Branch (1093:9): [True: 32.5k, False: 3.38M]
  ------------------
 1094|  32.5k|        return;
 1095|       |
 1096|  3.38M|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1096:9): [True: 0, False: 3.38M]
  ------------------
 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|  3.38M|    if (p->reverse_queue_complete && p->num_reverse_queue) {
  ------------------
  |  Branch (1109:9): [True: 0, False: 3.38M]
  |  Branch (1109:38): [True: 0, False: 0]
  ------------------
 1110|      0|        frame = p->reverse_queue[p->num_reverse_queue - 1];
 1111|      0|        p->num_reverse_queue -= 1;
 1112|      0|        goto output_frame;
 1113|      0|    }
 1114|  3.38M|    p->reverse_queue_complete = false;
 1115|       |
 1116|  3.38M|    frame = mp_pin_out_read(p->decoder->f->pins[1]);
 1117|  3.38M|    if (!frame.type)
  ------------------
  |  Branch (1117:9): [True: 2.53M, False: 845k]
  ------------------
 1118|  2.53M|        return;
 1119|       |
 1120|   845k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|   845k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1121|   845k|    if (p->attached_picture && frame.type == MP_FRAME_VIDEO)
  ------------------
  |  Branch (1121:9): [True: 0, False: 845k]
  |  Branch (1121:32): [True: 0, False: 0]
  ------------------
 1122|      0|        p->decoded_coverart = frame;
 1123|   845k|    if (p->attempt_framedrops) {
  ------------------
  |  Branch (1123:9): [True: 0, False: 845k]
  ------------------
 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|   845k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|   845k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1129|       |
 1130|   845k|    if (p->decoded_coverart.type) {
  ------------------
  |  Branch (1130:9): [True: 0, False: 845k]
  ------------------
 1131|      0|        mp_filter_internal_mark_progress(p->decf);
 1132|      0|        return;
 1133|      0|    }
 1134|       |
 1135|   845k|    p->packets_without_output = 0;
 1136|       |
 1137|   845k|    if (p->preroll_discard && frame.type != MP_FRAME_EOF) {
  ------------------
  |  Branch (1137:9): [True: 0, False: 845k]
  |  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|   845k|    bool segment_ended = process_decoded_frame(p, &frame);
 1148|       |
 1149|   845k|    if (p->play_dir < 0 && frame.type) {
  ------------------
  |  Branch (1149:9): [True: 0, False: 845k]
  |  Branch (1149:28): [True: 0, False: 0]
  ------------------
 1150|      0|        enqueue_backward_frame(p, frame);
 1151|      0|        frame = MP_NO_FRAME;
  ------------------
  |  |   58|      0|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
 1152|      0|    }
 1153|       |
 1154|       |    // If there's a new segment, start it as soon as we're drained/finished.
 1155|   845k|    if (segment_ended && p->new_segment) {
  ------------------
  |  Branch (1155:9): [True: 32.5k, False: 812k]
  |  Branch (1155:26): [True: 0, False: 32.5k]
  ------------------
 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|   845k|    if (!frame.type) {
  ------------------
  |  Branch (1179:9): [True: 0, False: 845k]
  ------------------
 1180|      0|        mp_filter_internal_mark_progress(p->decf); // make it retry
 1181|      0|        return;
 1182|      0|    }
 1183|       |
 1184|   845k|output_frame:
 1185|   845k|    process_output_frame(p, frame);
 1186|   845k|    p->eof_output = frame.type == MP_FRAME_EOF;
 1187|   845k|    mp_pin_in_write(pin, frame);
 1188|   845k|}
f_decoder_wrapper.c:process_decoded_frame:
  786|   845k|{
  787|   845k|    if (frame->type == MP_FRAME_EOF) {
  ------------------
  |  Branch (787:9): [True: 32.5k, False: 812k]
  ------------------
  788|       |        // if we were just draining current segment, don't propagate EOF
  789|  32.5k|        if (p->new_segment)
  ------------------
  |  Branch (789:13): [True: 0, False: 32.5k]
  ------------------
  790|      0|            mp_frame_unref(frame);
  791|  32.5k|        return true;
  792|  32.5k|    }
  793|       |
  794|   845k|    bool segment_ended = false;
  795|       |
  796|   812k|    if (frame->type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (796:9): [True: 812k, False: 0]
  ------------------
  797|   812k|        struct mp_image *mpi = frame->data;
  798|       |
  799|   812k|        crazy_video_pts_stuff(p, mpi);
  800|       |
  801|   812k|        struct demux_packet *ccpkt = new_demux_packet_from_buf(p->public.f->packet_pool,
  802|   812k|                                                               mpi->a53_cc);
  803|   812k|        if (ccpkt) {
  ------------------
  |  Branch (803:13): [True: 0, False: 812k]
  ------------------
  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|   812k|        if (mpi->pts == MP_NOPTS_VALUE || mpi->pts >= p->start_pts)
  ------------------
  |  |   39|  1.62M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (811:13): [True: 0, False: 812k]
  |  Branch (811:43): [True: 812k, False: 0]
  ------------------
  812|   812k|            p->start_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  813|       |
  814|   812k|        if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (814:13): [True: 812k, False: 0]
  ------------------
  815|   812k|            segment_ended = p->end != MP_NOPTS_VALUE && mpi->pts >= p->end;
  ------------------
  |  |   39|  1.62M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (815:29): [True: 0, False: 812k]
  |  Branch (815:57): [True: 0, False: 0]
  ------------------
  816|   812k|            if ((p->start != MP_NOPTS_VALUE && mpi->pts < p->start) ||
  ------------------
  |  |   39|  1.62M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (816:18): [True: 0, False: 812k]
  |  Branch (816:48): [True: 0, False: 0]
  ------------------
  817|   812k|                segment_ended)
  ------------------
  |  Branch (817:17): [True: 0, False: 812k]
  ------------------
  818|      0|            {
  819|      0|                mp_frame_unref(frame);
  820|      0|                goto done;
  821|      0|            }
  822|   812k|        }
  823|   812k|    } else if (frame->type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (823:16): [True: 0, False: 0]
  ------------------
  824|      0|        struct mp_aframe *aframe = frame->data;
  825|       |
  826|      0|        mp_aframe_clip_timestamps(aframe, p->start, p->end);
  827|      0|        double pts = mp_aframe_get_pts(aframe);
  828|      0|        if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts != MP_NOPTS_VALUE && p->start != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (828:13): [True: 0, False: 0]
  |  Branch (828:38): [True: 0, False: 0]
  ------------------
  829|      0|            segment_ended = pts >= p->end;
  830|       |
  831|      0|        if (mp_aframe_get_size(aframe) == 0) {
  ------------------
  |  Branch (831:13): [True: 0, False: 0]
  ------------------
  832|      0|            mp_frame_unref(frame);
  833|      0|            goto done;
  834|      0|        }
  835|      0|    } 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|   812k|done:
  840|   812k|    return segment_ended;
  841|   812k|}
f_decoder_wrapper.c:crazy_video_pts_stuff:
  749|   812k|{
  750|       |    // Note: the PTS is reordered, but the DTS is not. Both must be monotonic.
  751|       |
  752|   812k|    if (mpi->pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (752:9): [True: 812k, False: 0]
  ------------------
  753|   812k|        if (mpi->pts < p->codec_pts)
  ------------------
  |  Branch (753:13): [True: 0, False: 812k]
  ------------------
  754|      0|            p->num_codec_pts_problems++;
  755|   812k|        p->codec_pts = mpi->pts;
  756|   812k|    }
  757|       |
  758|   812k|    if (mpi->dts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (758:9): [True: 812k, False: 0]
  ------------------
  759|   812k|        if (mpi->dts <= p->codec_dts)
  ------------------
  |  Branch (759:13): [True: 0, False: 812k]
  ------------------
  760|      0|            p->num_codec_dts_problems++;
  761|   812k|        p->codec_dts = mpi->dts;
  762|   812k|    }
  763|       |
  764|   812k|    if (p->has_broken_packet_pts < 0)
  ------------------
  |  Branch (764:9): [True: 325k, False: 487k]
  ------------------
  765|   325k|        p->has_broken_packet_pts++;
  766|   812k|    if (p->num_codec_pts_problems)
  ------------------
  |  Branch (766:9): [True: 0, False: 812k]
  ------------------
  767|      0|        p->has_broken_packet_pts = 1;
  768|       |
  769|       |    // If PTS is unset, or non-monotonic, fall back to DTS.
  770|   812k|    if ((p->num_codec_pts_problems > p->num_codec_dts_problems ||
  ------------------
  |  Branch (770:10): [True: 0, False: 812k]
  ------------------
  771|   812k|        mpi->pts == MP_NOPTS_VALUE) && mpi->dts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   812k|#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: 812k]
  |  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|   812k|    if (p->decoder && p->decoder->control && p->codec->avi_dts &&
  ------------------
  |  Branch (775:9): [True: 812k, False: 0]
  |  Branch (775:23): [True: 812k, False: 0]
  |  Branch (775:46): [True: 0, False: 812k]
  ------------------
  776|      0|        mpi->pts != MP_NOPTS_VALUE && p->fps > 0)
  ------------------
  |  |   39|   812k|#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|   812k|}
f_decoder_wrapper.c:process_output_frame:
  922|   845k|{
  923|   845k|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (923:9): [True: 812k, False: 32.5k]
  ------------------
  924|   812k|        struct mp_image *mpi = frame.data;
  925|       |
  926|   812k|        correct_video_pts(p, mpi);
  927|       |
  928|   812k|        if (!mp_image_params_equal(&p->last_format, &mpi->params)) {
  ------------------
  |  Branch (928:13): [True: 32.5k, False: 780k]
  ------------------
  929|  32.5k|            fix_image_params(p, &mpi->params,
  930|  32.5k|                mp_image_params_static_equal(&p->last_format, &mpi->params));
  931|  32.5k|        }
  932|       |
  933|   812k|        mpi->params = p->fixed_format;
  934|   812k|        mpi->nominal_fps = p->fps;
  935|   812k|    } else if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (935:16): [True: 0, False: 32.5k]
  ------------------
  936|      0|        struct mp_aframe *aframe = frame.data;
  937|       |
  938|      0|        if (p->play_dir < 0 && !mp_aframe_reverse(aframe))
  ------------------
  |  Branch (938:13): [True: 0, False: 0]
  |  Branch (938:32): [True: 0, False: 0]
  ------------------
  939|      0|            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|      0|        correct_audio_pts(p, aframe);
  942|      0|    }
  943|   845k|}
f_decoder_wrapper.c:correct_video_pts:
  844|   812k|{
  845|   812k|    mpi->pts *= p->play_dir;
  846|       |
  847|   812k|    if (!p->opts->correct_pts || mpi->pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (847:9): [True: 0, False: 812k]
  |  Branch (847:34): [True: 0, False: 812k]
  ------------------
  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|   812k|    p->pts = mpi->pts;
  871|   812k|}
f_decoder_wrapper.c:fix_image_params:
  628|  32.5k|{
  629|  32.5k|    struct mp_image_params m = *params;
  630|  32.5k|    struct mp_codec_params *c = p->codec;
  631|  32.5k|    struct dec_wrapper_opts *opts = p->opts;
  632|       |
  633|  32.5k|    if (!quiet)
  ------------------
  |  Branch (633:9): [True: 32.5k, False: 0]
  ------------------
  634|  32.5k|        MP_VERBOSE(p, "Decoder format: %s\n", mp_image_params_to_str(params));
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  635|  32.5k|    p->dec_format = *params;
  636|       |
  637|  32.5k|    if (!quiet && opts->movie_aspect == 0)
  ------------------
  |  Branch (637:9): [True: 32.5k, False: 0]
  |  Branch (637:19): [True: 0, False: 32.5k]
  ------------------
  638|  32.5k|        MP_WARN(p, "Setting video-aspect-override to 0 is deprecated.\n"
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  639|  32.5k|                   "Use --video-aspect-override=no --video-aspect-mode=ignore instead.\n");
  640|  32.5k|    if (!quiet && opts->movie_aspect == -1)
  ------------------
  |  Branch (640:9): [True: 32.5k, False: 0]
  |  Branch (640:19): [True: 0, False: 32.5k]
  ------------------
  641|  32.5k|        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|  32.5k|                   "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|  32.5k|    bool use_container = true;
  647|  32.5k|    if (opts->aspect_method == 1 && m.p_w > 0 && m.p_h > 0 &&
  ------------------
  |  Branch (647:9): [True: 0, False: 32.5k]
  |  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|  32.5k|    if (opts->aspect_method == 3 && opts->movie_aspect != -1) {
  ------------------
  |  Branch (654:9): [True: 0, False: 32.5k]
  |  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|  32.5k|    if (use_container && c->dar_w > 0 && c->dar_h > 0) {
  ------------------
  |  Branch (661:9): [True: 32.5k, False: 0]
  |  Branch (661:26): [True: 0, False: 32.5k]
  |  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|  32.5k|    } else if (use_container && c->par_w > 0 && c->par_h) {
  ------------------
  |  Branch (665:16): [True: 32.5k, False: 0]
  |  Branch (665:33): [True: 32.5k, False: 0]
  |  Branch (665:49): [True: 32.5k, False: 0]
  ------------------
  666|  32.5k|        if (!quiet)
  ------------------
  |  Branch (666:13): [True: 32.5k, False: 0]
  ------------------
  667|  32.5k|            MP_VERBOSE(p, "Using container aspect ratio.\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  668|  32.5k|        m.p_w = c->par_w;
  669|  32.5k|        m.p_h = c->par_h;
  670|  32.5k|    }
  671|       |
  672|  32.5k|    if (opts->movie_aspect >= 0) {
  ------------------
  |  Branch (672:9): [True: 0, False: 32.5k]
  ------------------
  673|      0|        if (!quiet)
  ------------------
  |  Branch (673:13): [True: 0, False: 0]
  ------------------
  674|      0|            MP_VERBOSE(p, "Forcing user-set aspect ratio.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  675|      0|        if (opts->movie_aspect == 0) {
  ------------------
  |  Branch (675:13): [True: 0, False: 0]
  ------------------
  676|      0|            m.p_w = m.p_h = 1;
  677|      0|        } else {
  678|      0|            AVRational a = av_d2q(opts->movie_aspect, INT_MAX);
  679|      0|            mp_image_params_set_dsize(&m, a.num, a.den);
  680|      0|        }
  681|      0|    }
  682|       |
  683|       |    // Assume square pixels if no aspect ratio is set at all.
  684|  32.5k|    if (m.p_w <= 0 || m.p_h <= 0)
  ------------------
  |  Branch (684:9): [True: 0, False: 32.5k]
  |  Branch (684:23): [True: 0, False: 32.5k]
  ------------------
  685|      0|        m.p_w = m.p_h = 1;
  686|       |
  687|  32.5k|    if (!m.stereo3d)
  ------------------
  |  Branch (687:9): [True: 32.5k, False: 0]
  ------------------
  688|  32.5k|        m.stereo3d = p->codec->stereo_mode;
  689|       |
  690|  32.5k|    if (!mp_rect_equals(&p->codec->crop, &(struct mp_rect){0})) {
  ------------------
  |  Branch (690:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    if (opts->video_rotate < 0) {
  ------------------
  |  Branch (709:9): [True: 0, False: 32.5k]
  ------------------
  710|      0|        m.rotate = 0;
  711|  32.5k|    } else {
  712|       |        // ffmpeg commit 535a835e51 says that frame rotate takes priority
  713|  32.5k|        if (!m.rotate)
  ------------------
  |  Branch (713:13): [True: 32.5k, False: 0]
  ------------------
  714|  32.5k|            m.rotate = p->codec->rotate;
  715|  32.5k|        m.rotate = (m.rotate + opts->video_rotate) % 360;
  716|  32.5k|    }
  717|       |
  718|  32.5k|    pl_color_space_merge(&m.color, &c->color);
  719|  32.5k|    pl_color_repr_merge(&m.repr, &c->repr);
  720|       |
  721|  32.5k|    if (m.chroma_location == PL_CHROMA_UNKNOWN)
  ------------------
  |  Branch (721:9): [True: 32.5k, False: 0]
  ------------------
  722|  32.5k|        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|  32.5k|    mp_image_params_guess_csp(&m);
  727|       |
  728|  32.5k|    p->last_format = *params;
  729|  32.5k|    p->fixed_format = m;
  730|  32.5k|}
f_decoder_wrapper.c:decf_reset:
  336|  65.0k|{
  337|  65.0k|    struct priv *p = f->priv;
  338|  65.0k|    mp_assert(p->decf == f);
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (338:5): [True: 65.0k, False: 0]
  ------------------
  339|       |
  340|  65.0k|    p->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  65.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  341|  65.0k|    p->last_format = p->fixed_format = (struct mp_image_params){0};
  342|       |
  343|  65.0k|    mp_mutex_lock(&p->cache_lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  344|  65.0k|    p->pts_reset = false;
  345|  65.0k|    p->attempt_framedrops = 0;
  346|  65.0k|    p->dropped_frames = 0;
  347|  65.0k|    mp_mutex_unlock(&p->cache_lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  348|       |
  349|  65.0k|    p->coverart_returned = 0;
  350|  65.0k|    p->eof_output = false;
  351|       |
  352|  65.0k|    for (int n = 0; n < p->num_reverse_queue; n++)
  ------------------
  |  Branch (352:21): [True: 0, False: 65.0k]
  ------------------
  353|      0|        mp_frame_unref(&p->reverse_queue[n]);
  354|  65.0k|    p->num_reverse_queue = 0;
  355|  65.0k|    p->reverse_queue_byte_size = 0;
  356|  65.0k|    p->reverse_queue_complete = false;
  357|       |
  358|  65.0k|    reset_decoder(p);
  359|  65.0k|}

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

mp_output_chain_set_vo:
  393|  32.5k|{
  394|  32.5k|    struct chain *p = c->f->priv;
  395|       |
  396|  32.5k|    p->stream_info.hwdec_devs = vo ? vo->hwdec_devs : NULL;
  ------------------
  |  Branch (396:33): [True: 32.5k, False: 0]
  ------------------
  397|  32.5k|    p->stream_info.osd = vo ? vo->osd : NULL;
  ------------------
  |  Branch (397:26): [True: 32.5k, False: 0]
  ------------------
  398|  32.5k|    p->stream_info.vflip = vo ? vo->driver->caps & VO_CAP_VFLIP : false;
  ------------------
  |  Branch (398:28): [True: 32.5k, False: 0]
  ------------------
  399|  32.5k|    p->stream_info.rotate90 = vo ? vo->driver->caps & VO_CAP_ROTATE90 : false;
  ------------------
  |  Branch (399:31): [True: 32.5k, False: 0]
  ------------------
  400|  32.5k|    p->stream_info.dr_vo = vo;
  401|  32.5k|    p->vo = vo;
  402|  32.5k|    update_output_caps(p);
  403|  32.5k|}
mp_output_chain_set_el_stream:
  407|   974k|{
  408|   974k|    struct chain *p = c->f->priv;
  409|       |
  410|   974k|    mp_assert(p->type == MP_OUTPUT_CHAIN_VIDEO);
  ------------------
  |  |   41|   974k|#define mp_assert assert
  ------------------
  |  Branch (410:5): [True: 974k, False: 0]
  ------------------
  411|       |
  412|   974k|    if (p->el_sh == el_sh && (!el_sh || p->el_pair))
  ------------------
  |  Branch (412:9): [True: 974k, False: 0]
  |  Branch (412:31): [True: 974k, False: 0]
  |  Branch (412:41): [True: 0, False: 0]
  ------------------
  413|   974k|        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_update_filters:
  595|  32.5k|{
  596|  32.5k|    struct chain *p = c->f->priv;
  597|       |
  598|  32.5k|    struct mp_user_filter **add = NULL;      // new filters
  599|  32.5k|    int num_add = 0;
  600|  32.5k|    struct mp_user_filter **res = NULL;      // new final list
  601|  32.5k|    int num_res = 0;
  602|  32.5k|    bool *used = talloc_zero_array(NULL, bool, p->num_user_filters);
  ------------------
  |  |   30|  32.5k|#define talloc_zero_array               ta_xznew_array
  |  |  ------------------
  |  |  |  |  136|  32.5k|#define ta_xznew_array(...)             ta_oom_g(ta_znew_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|       |
  604|  65.0k|    for (int n = 0; list && list[n].name; n++) {
  ------------------
  |  Branch (604:21): [True: 65.0k, False: 0]
  |  Branch (604:29): [True: 32.5k, False: 32.5k]
  ------------------
  605|  32.5k|        struct m_obj_settings *entry = &list[n];
  606|       |
  607|  32.5k|        if (!entry->enabled)
  ------------------
  |  Branch (607:13): [True: 0, False: 32.5k]
  ------------------
  608|      0|            continue;
  609|       |
  610|  32.5k|        struct mp_user_filter *u = NULL;
  611|       |
  612|  32.5k|        for (int i = 0; i < p->num_user_filters; i++) {
  ------------------
  |  Branch (612:25): [True: 0, False: 32.5k]
  ------------------
  613|      0|            if (!used[i] && m_obj_settings_equal(entry, p->user_filters[i]->args))
  ------------------
  |  Branch (613:17): [True: 0, False: 0]
  |  Branch (613:29): [True: 0, False: 0]
  ------------------
  614|      0|            {
  615|      0|                u = p->user_filters[i];
  616|      0|                used[i] = true;
  617|      0|                break;
  618|      0|            }
  619|      0|        }
  620|       |
  621|  32.5k|        if (!u) {
  ------------------
  |  Branch (621:13): [True: 32.5k, False: 0]
  ------------------
  622|  32.5k|            u = create_wrapper_filter(p);
  623|  32.5k|            u->name = talloc_strdup(u, entry->name);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  624|  32.5k|            u->label = talloc_strdup(u, entry->label);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  625|  32.5k|            u->f = mp_create_user_filter(u->wrapper, p->type, entry->name,
  626|  32.5k|                                         entry->attribs);
  627|  32.5k|            if (!u->f) {
  ------------------
  |  Branch (627:17): [True: 0, False: 32.5k]
  ------------------
  628|      0|                talloc_free(u->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  629|      0|                goto error;
  630|      0|            }
  631|       |
  632|  32.5k|            struct m_obj_settings *args = (struct m_obj_settings[2]){*entry, {0}};
  633|       |
  634|  32.5k|            struct m_option dummy = {.type = &m_option_type_obj_settings_list};
  635|  32.5k|            m_option_copy(&dummy, &u->args, &args);
  636|       |
  637|  32.5k|            MP_TARRAY_APPEND(NULL, add, num_add, u);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  638|  32.5k|        }
  639|       |
  640|  32.5k|        MP_TARRAY_APPEND(p, res, num_res, u);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  641|  32.5k|    }
  642|       |
  643|       |    // At this point we definitely know we'll use the new list, so clean up.
  644|       |
  645|  32.5k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (645:21): [True: 0, False: 32.5k]
  ------------------
  646|      0|        if (!used[n])
  ------------------
  |  Branch (646:13): [True: 0, False: 0]
  ------------------
  647|      0|            talloc_free(p->user_filters[n]->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  648|      0|    }
  649|       |
  650|  32.5k|    talloc_free(p->user_filters);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  651|  32.5k|    p->user_filters = res;
  652|  32.5k|    p->num_user_filters = num_res;
  653|       |
  654|  32.5k|    relink_filter_list(p);
  655|       |
  656|  65.0k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (656:21): [True: 32.5k, False: 32.5k]
  ------------------
  657|  32.5k|        struct mp_user_filter *u = p->user_filters[n];
  658|  32.5k|        if (u->generated_label)
  ------------------
  |  Branch (658:13): [True: 0, False: 32.5k]
  ------------------
  659|      0|            TA_FREEP(&u->label);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  660|  32.5k|        if (!u->label) {
  ------------------
  |  Branch (660:13): [True: 32.5k, False: 0]
  ------------------
  661|  32.5k|            for (int i = 0; i < 100; i++) {
  ------------------
  |  Branch (661:29): [True: 32.5k, False: 0]
  ------------------
  662|  32.5k|                char *label = mp_tprintf(80, "%s.%02d", u->name, i);
  ------------------
  |  |  195|  32.5k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
  663|  32.5k|                if (!find_by_label(p, label)) {
  ------------------
  |  Branch (663:21): [True: 32.5k, False: 0]
  ------------------
  664|  32.5k|                    u->label = talloc_strdup(u, label);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  665|  32.5k|                    u->generated_label = true;
  666|  32.5k|                    break;
  667|  32.5k|                }
  668|  32.5k|            }
  669|  32.5k|        }
  670|  32.5k|    }
  671|       |
  672|  32.5k|    MP_VERBOSE(p, "User filter list:\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  673|  65.0k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (673:21): [True: 32.5k, False: 32.5k]
  ------------------
  674|  32.5k|        struct mp_user_filter *u = p->user_filters[n];
  675|  32.5k|        MP_VERBOSE(p, "  %s (%s)\n", u->name, u->label ? u->label : "-");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  65.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  676|  32.5k|    }
  677|  32.5k|    if (!p->num_user_filters)
  ------------------
  |  Branch (677:9): [True: 0, False: 32.5k]
  ------------------
  678|  32.5k|        MP_VERBOSE(p, "  (empty)\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__)
  |  |  ------------------
  ------------------
  679|       |
  680|       |    // Filters can load hwdec interops, which might add new formats.
  681|  32.5k|    update_output_caps(p);
  682|       |
  683|  32.5k|    mp_filter_wakeup(p->f);
  684|       |
  685|  32.5k|    talloc_free(add);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  686|  32.5k|    talloc_free(used);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  687|  32.5k|    return true;
  688|       |
  689|      0|error:
  690|      0|    for (int n = 0; n < num_add; n++)
  ------------------
  |  Branch (690:21): [True: 0, False: 0]
  ------------------
  691|      0|        talloc_free(add[n]->wrapper);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  692|      0|    talloc_free(add);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  693|      0|    talloc_free(used);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  694|       |    return false;
  695|  32.5k|}
mp_output_chain_create:
  743|  32.5k|{
  744|  32.5k|    struct mp_filter *f = mp_filter_create(parent, &output_chain_filter);
  745|  32.5k|    if (!f)
  ------------------
  |  Branch (745:9): [True: 0, False: 32.5k]
  ------------------
  746|      0|        return NULL;
  747|       |
  748|  32.5k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  749|  32.5k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  750|       |
  751|  32.5k|    const char *log_name = NULL;
  752|  32.5k|    switch (type) {
  ------------------
  |  Branch (752:13): [True: 32.5k, False: 0]
  ------------------
  753|  32.5k|    case MP_OUTPUT_CHAIN_VIDEO: log_name = "!vf"; break;
  ------------------
  |  Branch (753:5): [True: 32.5k, False: 0]
  ------------------
  754|      0|    case MP_OUTPUT_CHAIN_AUDIO: log_name = "!af"; break;
  ------------------
  |  Branch (754:5): [True: 0, False: 32.5k]
  ------------------
  755|  32.5k|    }
  756|  32.5k|    if (log_name)
  ------------------
  |  Branch (756:9): [True: 32.5k, False: 0]
  ------------------
  757|  32.5k|        f->log = mp_log_new(f, parent->global->log, log_name);
  758|       |
  759|  32.5k|    struct chain *p = f->priv;
  760|  32.5k|    p->f = f;
  761|  32.5k|    p->log = f->log;
  762|  32.5k|    p->type = type;
  763|       |
  764|  32.5k|    struct mp_output_chain *c = &p->public;
  765|  32.5k|    c->f = f;
  766|  32.5k|    c->input_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  32.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  32.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  767|  32.5k|    c->output_aformat = talloc_steal(p, mp_aframe_create());
  ------------------
  |  |   38|  32.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  32.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|  32.5k|    p->input = create_wrapper_filter(p);
  771|  32.5k|    p->input->f = mp_bidir_nop_filter_create(p->input->wrapper);
  772|  32.5k|    if (!p->input->f)
  ------------------
  |  Branch (772:9): [True: 0, False: 32.5k]
  ------------------
  773|      0|        abort();
  774|  32.5k|    p->input->name = "in";
  775|  32.5k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, p->input);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  776|       |
  777|  32.5k|    switch (type) {
  ------------------
  |  Branch (777:13): [True: 32.5k, False: 0]
  ------------------
  778|  32.5k|    case MP_OUTPUT_CHAIN_VIDEO: create_video_things(p); break;
  ------------------
  |  Branch (778:5): [True: 32.5k, False: 0]
  ------------------
  779|      0|    case MP_OUTPUT_CHAIN_AUDIO: create_audio_things(p); break;
  ------------------
  |  Branch (779:5): [True: 0, False: 32.5k]
  ------------------
  780|  32.5k|    }
  781|       |
  782|  32.5k|    p->convert_wrapper = create_wrapper_filter(p);
  783|  32.5k|    p->convert = mp_autoconvert_create(p->convert_wrapper->wrapper);
  784|  32.5k|    if (!p->convert)
  ------------------
  |  Branch (784:9): [True: 0, False: 32.5k]
  ------------------
  785|      0|        abort();
  786|  32.5k|    p->convert_wrapper->name = "convert";
  787|  32.5k|    p->convert_wrapper->f = p->convert->f;
  788|  32.5k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->convert_wrapper);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  789|       |
  790|  32.5k|    if (type == MP_OUTPUT_CHAIN_AUDIO) {
  ------------------
  |  Branch (790:9): [True: 0, False: 32.5k]
  ------------------
  791|      0|        p->convert->on_audio_format_change = on_audio_format_change;
  792|      0|        p->convert->on_audio_format_change_opaque = p;
  793|      0|    }
  794|       |
  795|       |    // Dummy filter for reporting and logging the output format.
  796|  32.5k|    p->output = create_wrapper_filter(p);
  797|  32.5k|    p->output->f = mp_bidir_nop_filter_create(p->output->wrapper);
  798|  32.5k|    if (!p->output->f)
  ------------------
  |  Branch (798:9): [True: 0, False: 32.5k]
  ------------------
  799|      0|        abort();
  800|  32.5k|    p->output->name = "out";
  801|  32.5k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, p->output);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 32.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.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|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  802|       |
  803|  32.5k|    relink_filter_list(p);
  804|       |
  805|  32.5k|    output_chain_reset(f);
  806|       |
  807|  32.5k|    return c;
  808|  32.5k|}
f_output_chain.c:update_output_caps:
   85|  97.5k|{
   86|  97.5k|    if (p->type != MP_OUTPUT_CHAIN_VIDEO)
  ------------------
  |  Branch (86:9): [True: 0, False: 97.5k]
  ------------------
   87|      0|        return;
   88|       |
   89|  97.5k|    mp_autoconvert_clear(p->convert);
   90|       |
   91|  97.5k|    if (p->vo) {
  ------------------
  |  Branch (91:9): [True: 97.5k, False: 0]
  ------------------
   92|  97.5k|        uint8_t allowed_output_formats[IMGFMT_END - IMGFMT_START] = {0};
   93|  97.5k|        vo_query_formats(p->vo, allowed_output_formats);
   94|       |
   95|  54.6M|        for (int n = 0; n < MP_ARRAY_SIZE(allowed_output_formats); n++) {
  ------------------
  |  |   49|  54.6M|#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
  ------------------
  |  Branch (95:25): [True: 54.5M, False: 97.5k]
  ------------------
   96|  54.5M|            if (allowed_output_formats[n])
  ------------------
  |  Branch (96:17): [True: 54.5M, False: 0]
  ------------------
   97|  54.5M|                mp_autoconvert_add_imgfmt(p->convert, IMGFMT_START + n, 0);
   98|  54.5M|        }
   99|  97.5k|    }
  100|  97.5k|}
f_output_chain.c:create_wrapper_filter:
  258|   227k|{
  259|   227k|    struct mp_filter *f = mp_filter_create(p->f, &user_wrapper_filter);
  260|   227k|    if (!f)
  ------------------
  |  Branch (260:9): [True: 0, False: 227k]
  ------------------
  261|      0|        abort();
  262|   227k|    struct mp_user_filter *wrapper = f->priv;
  263|   227k|    wrapper->wrapper = f;
  264|   227k|    wrapper->p = p;
  265|   227k|    wrapper->last_in_aformat = talloc_steal(wrapper, mp_aframe_create());
  ------------------
  |  |   38|   227k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|   227k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  266|       |    wrapper->last_is_active = true;
  267|   227k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  268|   227k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  269|   227k|    return wrapper;
  270|   227k|}
f_output_chain.c:user_wrapper_destroy:
  240|   227k|{
  241|   227k|    struct mp_user_filter *u = f->priv;
  242|       |
  243|   227k|    struct m_option dummy = {.type = &m_option_type_obj_settings_list};
  244|   227k|    m_option_free(&dummy, &u->args);
  245|       |
  246|   227k|    mp_filter_free_children(f);
  247|   227k|}
f_output_chain.c:user_wrapper_process:
  157|  23.8M|{
  158|  23.8M|    struct mp_user_filter *u = f->priv;
  159|  23.8M|    struct chain *p = u->p;
  160|       |
  161|  23.8M|    mp_filter_set_error_handler(u->f, f);
  162|  23.8M|    const char *name = u->label ? u->label : u->name;
  ------------------
  |  Branch (162:24): [True: 3.41M, False: 20.4M]
  ------------------
  163|  23.8M|    mp_assert(u->name);
  ------------------
  |  |   41|  23.8M|#define mp_assert assert
  ------------------
  |  Branch (163:5): [True: 23.8M, False: 0]
  ------------------
  164|       |
  165|  23.8M|    if (!u->failed && mp_filter_has_failed(u->f)) {
  ------------------
  |  Branch (165:9): [True: 23.8M, False: 0]
  |  Branch (165:23): [True: 0, False: 23.8M]
  ------------------
  166|      0|        if (u == p->convert_wrapper) {
  ------------------
  |  Branch (166:13): [True: 0, False: 0]
  ------------------
  167|       |            // This is a fuckup we can't ignore.
  168|      0|            MP_FATAL(p, "Cannot convert decoder/filter output to any format "
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  169|      0|                     "supported by the output.\n");
  170|      0|            p->public.failed_output_conversion = true;
  171|      0|            mp_filter_wakeup(p->f);
  172|      0|        } else {
  173|      0|            MP_ERR(p, "Disabling filter %s because it has failed.\n", name);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  174|      0|            mp_filter_reset(u->f); // clear out staled buffered data
  175|      0|        }
  176|      0|        u->failed = true;
  177|      0|    }
  178|       |
  179|  23.8M|    if (u->failed) {
  ------------------
  |  Branch (179:9): [True: 0, False: 23.8M]
  ------------------
  180|       |        // The convert_wrapper failure is fatal so we must signal EOF. Similarly,
  181|       |        // if this wrapper forwarded EOF into the inner filter, that EOF may
  182|       |        // be lost. Reset filter may have discarded this frame from failed filter.
  183|       |        // Synthesize EOF so downstream doesn't stall indefinitely.
  184|      0|        if (u == p->convert_wrapper || u->in_eof) {
  ------------------
  |  Branch (184:13): [True: 0, False: 0]
  |  Branch (184:40): [True: 0, False: 0]
  ------------------
  185|      0|            if (mp_pin_in_needs_data(f->ppins[1])) {
  ------------------
  |  Branch (185:17): [True: 0, False: 0]
  ------------------
  186|      0|                if (!u->error_eof_sent)
  ------------------
  |  Branch (186:21): [True: 0, False: 0]
  ------------------
  187|      0|                    mp_pin_in_write(f->ppins[1], MP_EOF_FRAME);
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  188|      0|                u->error_eof_sent = true;
  189|      0|            }
  190|      0|            return;
  191|      0|        }
  192|       |
  193|      0|        mp_pin_transfer_data(f->ppins[1], f->ppins[0]);
  194|      0|        return;
  195|      0|    }
  196|       |
  197|  23.8M|    if (mp_pin_can_transfer_data(u->f->pins[0], f->ppins[0])) {
  ------------------
  |  Branch (197:9): [True: 5.91M, False: 17.9M]
  ------------------
  198|  5.91M|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  199|       |
  200|  5.91M|        check_in_format_change(u, frame);
  201|       |
  202|  5.91M|        double pts = mp_frame_get_pts(frame);
  203|  5.91M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  5.91M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (203:13): [True: 5.69M, False: 227k]
  ------------------
  204|  5.69M|            u->last_in_pts = pts;
  205|       |
  206|  5.91M|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (206:13): [True: 227k, False: 5.69M]
  ------------------
  207|   227k|            u->in_eof = true;
  208|       |
  209|  5.91M|        mp_pin_in_write(u->f->pins[0], frame);
  210|  5.91M|    }
  211|       |
  212|  23.8M|    if (mp_pin_can_transfer_data(f->ppins[1], u->f->pins[1])) {
  ------------------
  |  Branch (212:9): [True: 5.91M, False: 17.9M]
  ------------------
  213|  5.91M|        struct mp_frame frame = mp_pin_out_read(u->f->pins[1]);
  214|       |
  215|  5.91M|        double pts = mp_frame_get_pts(frame);
  216|  5.91M|        if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|  5.91M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (216:13): [True: 5.69M, False: 227k]
  ------------------
  217|  5.69M|            u->last_out_pts = pts;
  218|       |
  219|  5.91M|        mp_pin_in_write(f->ppins[1], frame);
  220|       |
  221|  5.91M|        struct mp_filter_command cmd = {.type = MP_FILTER_COMMAND_IS_ACTIVE};
  222|  5.91M|        if (mp_filter_command(u->f, &cmd) && u->last_is_active != cmd.is_active) {
  ------------------
  |  Branch (222:13): [True: 3.38M, False: 2.53M]
  |  Branch (222:46): [True: 130k, False: 3.25M]
  ------------------
  223|   130k|            u->last_is_active = cmd.is_active;
  224|   130k|            MP_VERBOSE(p, "[%s] (%sabled)\n", u->name,
  ------------------
  |  |   92|   130k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   260k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 130k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|   130k|                       u->last_is_active ? "en" : "dis");
  226|   130k|        }
  227|  5.91M|    }
  228|  23.8M|}
f_output_chain.c:check_in_format_change:
  104|  5.91M|{
  105|  5.91M|    struct chain *p = u->p;
  106|       |
  107|  5.91M|    if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (107:9): [True: 5.69M, False: 227k]
  ------------------
  108|  5.69M|        struct mp_image *img = frame.data;
  109|       |
  110|  5.69M|        if (!mp_image_params_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (110:13): [True: 227k, False: 5.46M]
  ------------------
  111|   227k|            if (u == p->input) {
  ------------------
  |  Branch (111:17): [True: 32.5k, False: 195k]
  ------------------
  112|  32.5k|                p->public.input_params = img->params;
  113|   195k|            } else if (u == p->output) {
  ------------------
  |  Branch (113:24): [True: 32.5k, False: 162k]
  ------------------
  114|  32.5k|                p->public.output_params = img->params;
  115|  32.5k|            }
  116|       |
  117|   227k|            if (!mp_image_params_static_equal(&img->params, &u->last_in_vformat)) {
  ------------------
  |  Branch (117:17): [True: 227k, False: 0]
  ------------------
  118|   227k|                MP_VERBOSE(p, "[%s] %s\n", u->name,
  ------------------
  |  |   92|   227k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   227k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  119|   227k|                           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|   227k|                if (strcmp(u->name, "convert") == 0)
  ------------------
  |  Branch (128:21): [True: 32.5k, False: 195k]
  ------------------
  129|  32.5k|                    update_output_caps(p);
  130|       |
  131|   227k|                p->public.reconfig_happened = true;
  132|   227k|            }
  133|   227k|            u->last_in_vformat = img->params;
  134|   227k|        }
  135|  5.69M|    }
  136|       |
  137|  5.91M|    if (frame.type == MP_FRAME_AUDIO) {
  ------------------
  |  Branch (137:9): [True: 0, False: 5.91M]
  ------------------
  138|      0|        struct mp_aframe *aframe = frame.data;
  139|       |
  140|      0|        if (!mp_aframe_config_equals(aframe, u->last_in_aformat)) {
  ------------------
  |  Branch (140:13): [True: 0, False: 0]
  ------------------
  141|      0|            MP_VERBOSE(p, "[%s] %s\n", u->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__)
  |  |  ------------------
  ------------------
  142|      0|                       mp_aframe_format_str(aframe));
  143|      0|            mp_aframe_config_copy(u->last_in_aformat, aframe);
  144|       |
  145|      0|            if (u == p->input) {
  ------------------
  |  Branch (145:17): [True: 0, False: 0]
  ------------------
  146|      0|                mp_aframe_config_copy(p->public.input_aformat, aframe);
  147|      0|            } else if (u == p->output) {
  ------------------
  |  Branch (147:24): [True: 0, False: 0]
  ------------------
  148|      0|                mp_aframe_config_copy(p->public.output_aformat, aframe);
  149|      0|            }
  150|       |
  151|       |            p->public.reconfig_happened = true;
  152|      0|        }
  153|      0|    }
  154|  5.91M|}
f_output_chain.c:relink_filter_list:
  274|  65.0k|{
  275|  65.0k|    struct mp_user_filter **all_filters[3] =
  276|  65.0k|        {p->pre_filters, p->user_filters, p->post_filters};
  277|  65.0k|    int all_filters_num[3] =
  278|  65.0k|        {p->num_pre_filters, p->num_user_filters, p->num_post_filters};
  279|  65.0k|    p->num_all_filters = 0;
  280|   260k|    for (int n = 0; n < 3; n++) {
  ------------------
  |  Branch (280:21): [True: 195k, False: 65.0k]
  ------------------
  281|   195k|        struct mp_user_filter **filters = all_filters[n];
  282|   195k|        int filters_num = all_filters_num[n];
  283|   617k|        for (int i = 0; i < filters_num; i++)
  ------------------
  |  Branch (283:25): [True: 422k, False: 195k]
  ------------------
  284|   422k|            MP_TARRAY_APPEND(p, p->all_filters, p->num_all_filters, filters[i]);
  ------------------
  |  |  105|   422k|    do {                                            \
  |  |  106|   422k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   422k|    do {                                            \
  |  |  |  |   97|   422k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   422k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   422k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   422k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 97.5k, False: 325k]
  |  |  |  |  ------------------
  |  |  |  |   99|   422k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  97.5k|    do {                                                        \
  |  |  |  |  |  |   89|  97.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  97.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  97.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  97.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  97.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  97.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  97.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 97.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   422k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 422k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   422k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   422k|        (idxvar)++;                                 \
  |  |  109|   422k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 422k]
  |  |  ------------------
  ------------------
  285|   195k|    }
  286|       |
  287|  65.0k|    mp_assert(p->num_all_filters > 0);
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (287:5): [True: 65.0k, False: 0]
  ------------------
  288|       |
  289|  65.0k|    p->filters_in = NULL;
  290|  65.0k|    p->filters_out = NULL;
  291|   487k|    for (int n = 0; n < p->num_all_filters; n++) {
  ------------------
  |  Branch (291:21): [True: 422k, False: 65.0k]
  ------------------
  292|   422k|        struct mp_filter *f = p->all_filters[n]->wrapper;
  293|   422k|        if (n == 0)
  ------------------
  |  Branch (293:13): [True: 65.0k, False: 357k]
  ------------------
  294|  65.0k|            p->filters_in = f->pins[0];
  295|   422k|        if (p->filters_out)
  ------------------
  |  Branch (295:13): [True: 357k, False: 65.0k]
  ------------------
  296|   357k|            mp_pin_connect(f->pins[0], p->filters_out);
  297|   422k|        p->filters_out = f->pins[1];
  298|   422k|    }
  299|       |
  300|  65.0k|    mp_pin_set_manual_connection_for(p->filters_in, p->f);
  301|  65.0k|    mp_pin_set_manual_connection_for(p->filters_out, p->f);
  302|  65.0k|}
f_output_chain.c:find_by_label:
  494|  32.5k|{
  495|  65.0k|    for (int n = 0; n < p->num_user_filters; n++) {
  ------------------
  |  Branch (495:21): [True: 32.5k, False: 32.5k]
  ------------------
  496|  32.5k|        struct mp_user_filter *u = p->user_filters[n];
  497|  32.5k|        if (label && u->label && strcmp(label, u->label) == 0)
  ------------------
  |  Branch (497:13): [True: 32.5k, False: 0]
  |  Branch (497:22): [True: 0, False: 32.5k]
  |  Branch (497:34): [True: 0, False: 0]
  ------------------
  498|      0|            return u;
  499|  32.5k|    }
  500|  32.5k|    return NULL;
  501|  32.5k|}
f_output_chain.c:output_chain_destroy:
  364|  32.5k|{
  365|  32.5k|    output_chain_reset(f);
  366|  32.5k|}
f_output_chain.c:output_chain_process:
  305|  3.38M|{
  306|  3.38M|    struct chain *p = f->priv;
  307|       |
  308|  3.38M|    if (mp_pin_can_transfer_data(p->filters_in, f->ppins[0])) {
  ------------------
  |  Branch (308:9): [True: 845k, False: 2.53M]
  ------------------
  309|   845k|        struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
  310|       |
  311|   845k|        if (frame.type == MP_FRAME_EOF)
  ------------------
  |  Branch (311:13): [True: 32.5k, False: 812k]
  ------------------
  312|   845k|            MP_VERBOSE(p, "filter input EOF\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  313|       |
  314|   845k|        if (frame.type == MP_FRAME_VIDEO && p->public.update_subtitles) {
  ------------------
  |  Branch (314:13): [True: 812k, False: 32.5k]
  |  Branch (314:45): [True: 812k, False: 0]
  ------------------
  315|   812k|            p->public.update_subtitles(p->public.update_subtitles_ctx,
  316|   812k|                                       mp_frame_get_pts(frame));
  317|   812k|        }
  318|       |
  319|   845k|        mp_pin_in_write(p->filters_in, frame);
  320|   845k|    }
  321|       |
  322|  3.38M|    if (mp_pin_can_transfer_data(f->ppins[1], p->filters_out)) {
  ------------------
  |  Branch (322:9): [True: 845k, False: 2.53M]
  ------------------
  323|   845k|        struct mp_frame frame = mp_pin_out_read(p->filters_out);
  324|       |
  325|   845k|        p->public.got_output_eof = frame.type == MP_FRAME_EOF;
  326|   845k|        if (p->public.got_output_eof)
  ------------------
  |  Branch (326:13): [True: 32.5k, False: 812k]
  ------------------
  327|   845k|            MP_VERBOSE(p, "filter output EOF\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  328|       |
  329|   845k|        mp_pin_in_write(f->ppins[1], frame);
  330|   845k|    }
  331|  3.38M|}
f_output_chain.c:create_video_things:
  698|  32.5k|{
  699|  32.5k|    p->frame_type = MP_FRAME_VIDEO;
  700|       |
  701|  32.5k|    p->stream_info.priv = p;
  702|  32.5k|    p->stream_info.get_display_fps = get_display_fps;
  703|  32.5k|    p->stream_info.get_display_res = get_display_res;
  704|       |
  705|  32.5k|    p->f->stream_info = &p->stream_info;
  706|       |
  707|  32.5k|    struct mp_user_filter *f = create_wrapper_filter(p);
  708|  32.5k|    f->name = "userdeint";
  709|  32.5k|    f->f = mp_deint_create(f->wrapper);
  710|  32.5k|    if (!f->f)
  ------------------
  |  Branch (710:9): [True: 0, False: 32.5k]
  ------------------
  711|      0|        abort();
  712|  32.5k|    MP_TARRAY_APPEND(p, p->pre_filters, p->num_pre_filters, f);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 32.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.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|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  713|       |
  714|  32.5k|    f = create_wrapper_filter(p);
  715|  32.5k|    f->name = "autovflip";
  716|  32.5k|    f->f = mp_autovflip_create(f->wrapper);
  717|  32.5k|    if (!f->f)
  ------------------
  |  Branch (717:9): [True: 0, False: 32.5k]
  ------------------
  718|      0|        abort();
  719|  32.5k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  720|       |
  721|  32.5k|    f = create_wrapper_filter(p);
  722|  32.5k|    f->name = "autorotate";
  723|  32.5k|    f->f = mp_autorotate_create(f->wrapper);
  724|  32.5k|    if (!f->f)
  ------------------
  |  Branch (724:9): [True: 0, False: 32.5k]
  ------------------
  725|      0|        abort();
  726|  32.5k|    MP_TARRAY_APPEND(p, p->post_filters, p->num_post_filters, f);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 32.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.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|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  727|  32.5k|}
f_output_chain.c:output_chain_reset:
  334|  65.0k|{
  335|  65.0k|    struct chain *p = f->priv;
  336|       |
  337|  65.0k|    p->public.ao_needs_update = false;
  338|       |
  339|       |    p->public.got_output_eof = false;
  340|  65.0k|}

mp_subfilter_read:
   94|  6.89M|{
   95|  6.89M|    if (sub->filter) {
  ------------------
  |  Branch (95:9): [True: 0, False: 6.89M]
  ------------------
   96|      0|        if (mp_pin_can_transfer_data(sub->out, sub->filter->pins[1])) {
  ------------------
  |  Branch (96:13): [True: 0, False: 0]
  ------------------
   97|      0|            struct mp_frame frame = mp_pin_out_read(sub->filter->pins[1]);
   98|      0|            if (sub->draining && frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (98:17): [True: 0, False: 0]
  |  Branch (98:34): [True: 0, False: 0]
  ------------------
   99|      0|                sub->draining = false;
  100|      0|                TA_FREEP(&sub->filter);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  101|      0|                mark_progress(sub);
  102|      0|                return false;
  103|      0|            }
  104|      0|            mp_pin_in_write(sub->out, frame);
  105|      0|            return false;
  106|      0|        }
  107|      0|        if (sub->draining)
  ------------------
  |  Branch (107:13): [True: 0, False: 0]
  ------------------
  108|      0|            return false;
  109|      0|    }
  110|       |
  111|  6.89M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (111:26): [True: 0, False: 6.89M]
  ------------------
  112|       |
  113|  6.89M|    if (sub->frame.type)
  ------------------
  |  Branch (113:9): [True: 0, False: 6.89M]
  ------------------
  114|      0|        return mp_pin_in_needs_data(out);
  115|       |
  116|  6.89M|    if (!mp_pin_can_transfer_data(out, sub->in))
  ------------------
  |  Branch (116:9): [True: 3.51M, False: 3.38M]
  ------------------
  117|  3.51M|        return false;
  118|       |
  119|  3.38M|    sub->frame = mp_pin_out_read(sub->in);
  120|       |    return true;
  121|  6.89M|}
mp_subfilter_reset:
  124|   130k|{
  125|   130k|    if (sub->filter && sub->draining)
  ------------------
  |  Branch (125:9): [True: 0, False: 130k]
  |  Branch (125:24): [True: 0, False: 0]
  ------------------
  126|      0|        TA_FREEP(&sub->filter);
  ------------------
  |  |   81|      0|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|      0|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 0]
  |  |  ------------------
  ------------------
  127|       |    sub->draining = false;
  128|   130k|    mp_frame_unref(&sub->frame);
  129|   130k|}
mp_subfilter_continue:
  132|  3.38M|{
  133|  3.38M|    struct mp_pin *out = sub->filter ? sub->filter->pins[0] : sub->out;
  ------------------
  |  Branch (133:26): [True: 0, False: 3.38M]
  ------------------
  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|  3.38M|    if (!mp_pin_in_needs_data(out)) {
  ------------------
  |  Branch (138:9): [True: 0, False: 3.38M]
  ------------------
  139|      0|        mark_progress(sub);
  140|      0|        return;
  141|      0|    }
  142|  3.38M|    mp_pin_in_write(out, sub->frame);
  143|  3.38M|    sub->frame = MP_NO_FRAME;
  ------------------
  |  |   58|  3.38M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  3.38M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  144|  3.38M|}
mp_subfilter_destroy:
  147|   845k|{
  148|   845k|    TA_FREEP(&sub->filter);
  ------------------
  |  |   81|   845k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   845k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 845k]
  |  |  ------------------
  ------------------
  149|       |    sub->draining = false;
  150|   845k|}
mp_subfilter_drain_destroy:
  153|  97.5k|{
  154|  97.5k|    if (!sub->draining && sub->filter) {
  ------------------
  |  Branch (154:9): [True: 97.5k, False: 0]
  |  Branch (154:27): [True: 0, False: 97.5k]
  ------------------
  155|       |        // We know the filter is writable (unless the user created a new filter
  156|       |        // and immediately called this function, which is invalid).
  157|      0|        mp_pin_in_write(sub->filter->pins[0], MP_EOF_FRAME);
  ------------------
  |  |   59|      0|#define MP_EOF_FRAME MAKE_FRAME(MP_FRAME_EOF, 0)
  |  |  ------------------
  |  |  |  |   57|      0|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  158|       |        sub->draining = true;
  159|      0|    }
  160|  97.5k|    return !sub->filter;
  161|  97.5k|}
mp_bidir_nop_filter_create:
  168|  65.0k|{
  169|  65.0k|    struct mp_filter *f = mp_filter_create(parent, &bidir_nop_filter);
  170|  65.0k|    if (!f)
  ------------------
  |  Branch (170:9): [True: 0, False: 65.0k]
  ------------------
  171|      0|        return NULL;
  172|       |
  173|  65.0k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  174|  65.0k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  175|       |
  176|  65.0k|    mp_pin_connect(f->ppins[1], f->ppins[0]);
  177|       |
  178|  65.0k|    return f;
  179|  65.0k|}

mp_filter_internal_mark_progress:
  190|   845k|{
  191|   845k|    struct filter_runner *r = f->in->runner;
  192|   845k|    mp_assert(r->filtering); // only call from f's process()
  ------------------
  |  |   41|   845k|#define mp_assert assert
  ------------------
  |  Branch (192:5): [True: 845k, False: 0]
  ------------------
  193|   845k|    add_pending(f);
  194|   845k|}
mp_filter_graph_run:
  212|  1.77M|{
  213|  1.77M|    struct filter_runner *r = filter->in->runner;
  214|  1.77M|    mp_assert(filter == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  1.77M|#define mp_assert assert
  ------------------
  |  Branch (214:5): [True: 1.77M, False: 0]
  ------------------
  215|       |
  216|  1.77M|    int64_t end_time = 0;
  217|  1.77M|    if (isfinite(r->max_run_time))
  ------------------
  |  Branch (217:9): [True: 1.77M, False: 0]
  ------------------
  218|  1.77M|        end_time = mp_time_ns_add(mp_time_ns(), MPMAX(r->max_run_time, 0));
  ------------------
  |  |   44|  1.77M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 1.77M, False: 0]
  |  |  ------------------
  ------------------
  219|       |
  220|       |    // (could happen with separate filter graphs calling each other, for now
  221|       |    // ignore this issue as we don't use such a setup anywhere)
  222|  1.77M|    mp_assert(!r->filtering);
  ------------------
  |  |   41|  1.77M|#define mp_assert assert
  ------------------
  |  Branch (222:5): [True: 1.77M, False: 0]
  ------------------
  223|       |
  224|  1.77M|    r->filtering = true;
  225|       |
  226|  1.77M|    flush_async_notifications(r);
  227|       |
  228|  1.77M|    bool exit_req = false;
  229|       |
  230|  45.5M|    while (1) {
  ------------------
  |  Branch (230:12): [True: 45.5M, Folded]
  ------------------
  231|  45.5M|        if (atomic_exchange_explicit(&r->interrupt_flag, false,
  ------------------
  |  Branch (231:13): [True: 87, False: 45.5M]
  ------------------
  232|  45.5M|                                     memory_order_acq_rel))
  233|     87|        {
  234|     87|            mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|     87|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  235|     87|            if (!r->async_wakeup_sent && r->wakeup_cb)
  ------------------
  |  Branch (235:17): [True: 87, False: 0]
  |  Branch (235:42): [True: 87, False: 0]
  ------------------
  236|     87|                r->wakeup_cb(r->wakeup_ctx);
  237|     87|            r->async_wakeup_sent = true;
  238|     87|            mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|     87|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  239|     87|            exit_req = true;
  240|     87|        }
  241|       |
  242|  45.5M|        if (!r->num_pending) {
  ------------------
  |  Branch (242:13): [True: 1.77M, False: 43.7M]
  ------------------
  243|  1.77M|            flush_async_notifications(r);
  244|  1.77M|            if (!r->num_pending)
  ------------------
  |  Branch (244:17): [True: 1.77M, False: 65]
  ------------------
  245|  1.77M|                break;
  246|  1.77M|        }
  247|       |
  248|  43.7M|        struct mp_filter *next = NULL;
  249|       |
  250|  43.7M|        if (r->pending[0]->in->high_priority) {
  ------------------
  |  Branch (250:13): [True: 0, False: 43.7M]
  ------------------
  251|      0|            next = r->pending[0];
  252|      0|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, 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 (252:13): [True: 0, False: 0]
  ------------------
  253|  43.7M|        } else if (!exit_req) {
  ------------------
  |  Branch (253:20): [True: 43.7M, False: 87]
  ------------------
  254|  43.7M|            next = r->pending[r->num_pending - 1];
  255|  43.7M|            r->num_pending -= 1;
  256|  43.7M|        }
  257|       |
  258|  43.7M|        if (!next)
  ------------------
  |  Branch (258:13): [True: 87, False: 43.7M]
  ------------------
  259|     87|            break;
  260|       |
  261|  43.7M|        next->in->pending = false;
  262|  43.7M|        if (next->in->info->process)
  ------------------
  |  Branch (262:13): [True: 42.7M, False: 975k]
  ------------------
  263|  42.7M|            next->in->info->process(next);
  264|       |
  265|  43.7M|        if (end_time && mp_time_ns() >= end_time)
  ------------------
  |  Branch (265:13): [True: 43.7M, False: 0]
  |  Branch (265:25): [True: 87, False: 43.7M]
  ------------------
  266|     87|            mp_filter_graph_interrupt(r->root_filter);
  267|  43.7M|    }
  268|       |
  269|  1.77M|    r->filtering = false;
  270|       |
  271|  1.77M|    bool externals = r->external_pending;
  272|       |    r->external_pending = false;
  273|  1.77M|    return externals;
  274|  1.77M|}
mp_pin_can_transfer_data:
  277|  63.1M|{
  278|  63.1M|    return mp_pin_in_needs_data(dst) && mp_pin_out_request_data(src);
  ------------------
  |  Branch (278:12): [True: 47.3M, False: 15.8M]
  |  Branch (278:41): [True: 17.7M, False: 29.5M]
  ------------------
  279|  63.1M|}
mp_pin_in_needs_data:
  290|  98.0M|{
  291|  98.0M|    mp_assert(p->dir == MP_PIN_IN);
  ------------------
  |  |   41|  98.0M|#define mp_assert assert
  ------------------
  |  Branch (291:5): [True: 98.0M, False: 0]
  ------------------
  292|  98.0M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|  98.0M|#define mp_assert assert
  ------------------
  |  Branch (292:5): [True: 98.0M, False: 0]
  ------------------
  293|  98.0M|    return p->conn && p->conn->manual_connection && p->conn->data_requested;
  ------------------
  |  Branch (293:12): [True: 98.0M, False: 0]
  |  Branch (293:23): [True: 98.0M, False: 0]
  |  Branch (293:53): [True: 80.3M, False: 17.6M]
  ------------------
  294|  98.0M|}
mp_pin_in_write:
  297|  21.1M|{
  298|  21.1M|    if (!mp_pin_in_needs_data(p) || frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (298:9): [True: 0, False: 21.1M]
  |  Branch (298:37): [True: 0, False: 21.1M]
  ------------------
  299|      0|        if (frame.type)
  ------------------
  |  Branch (299:13): [True: 0, False: 0]
  ------------------
  300|      0|            MP_ERR(p->owner, "losing frame on %s\n", p->name);
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  301|      0|        mp_frame_unref(&frame);
  302|      0|        return false;
  303|      0|    }
  304|  21.1M|    mp_assert(p->conn->data.type == MP_FRAME_NONE);
  ------------------
  |  |   41|  21.1M|#define mp_assert assert
  ------------------
  |  Branch (304:5): [True: 21.1M, False: 0]
  ------------------
  305|  21.1M|    p->conn->data = frame;
  306|  21.1M|    p->conn->data_requested = false;
  307|  21.1M|    add_pending_pin(p->conn);
  308|  21.1M|    filter_recursive(p);
  309|       |    return true;
  310|  21.1M|}
mp_pin_out_has_data:
  313|   107M|{
  314|   107M|    mp_assert(p->dir == MP_PIN_OUT);
  ------------------
  |  |   41|   107M|#define mp_assert assert
  ------------------
  |  Branch (314:5): [True: 107M, False: 0]
  ------------------
  315|   107M|    mp_assert(!p->within_conn);
  ------------------
  |  |   41|   107M|#define mp_assert assert
  ------------------
  |  Branch (315:5): [True: 107M, False: 0]
  ------------------
  316|   107M|    return p->conn && p->conn->manual_connection && p->data.type != MP_FRAME_NONE;
  ------------------
  |  Branch (316:12): [True: 107M, False: 0]
  |  Branch (316:23): [True: 107M, False: 0]
  |  Branch (316:53): [True: 38.8M, False: 68.5M]
  ------------------
  317|   107M|}
mp_pin_out_request_data:
  320|  72.7M|{
  321|  72.7M|    if (mp_pin_out_has_data(p))
  ------------------
  |  Branch (321:9): [True: 38.0M, False: 34.7M]
  ------------------
  322|  38.0M|        return true;
  323|  34.7M|    if (p->conn && p->conn->manual_connection) {
  ------------------
  |  Branch (323:9): [True: 34.7M, False: 0]
  |  Branch (323:20): [True: 34.7M, False: 0]
  ------------------
  324|  34.7M|        if (!p->data_requested) {
  ------------------
  |  Branch (324:13): [True: 21.1M, False: 13.5M]
  ------------------
  325|       |            p->data_requested = true;
  326|  21.1M|            add_pending_pin(p->conn);
  327|  21.1M|        }
  328|  34.7M|        filter_recursive(p);
  329|  34.7M|    }
  330|  34.7M|    return mp_pin_out_has_data(p);
  331|  72.7M|}
mp_pin_out_read:
  340|  25.4M|{
  341|  25.4M|    if (!mp_pin_out_request_data(p))
  ------------------
  |  Branch (341:9): [True: 4.28M, False: 21.1M]
  ------------------
  342|  4.28M|        return MP_NO_FRAME;
  ------------------
  |  |   58|  4.28M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  4.28M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  343|  21.1M|    struct mp_frame res = p->data;
  344|  21.1M|    p->data = MP_NO_FRAME;
  ------------------
  |  |   58|  21.1M|#define MP_NO_FRAME MAKE_FRAME(0, 0)
  |  |  ------------------
  |  |  |  |   57|  21.1M|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  |  |  ------------------
  ------------------
  345|  21.1M|    return res;
  346|  25.4M|}
mp_pin_connect:
  438|   487k|{
  439|   487k|    mp_assert(src->dir == MP_PIN_OUT);
  ------------------
  |  |   41|   487k|#define mp_assert assert
  ------------------
  |  Branch (439:5): [True: 487k, False: 0]
  ------------------
  440|   487k|    mp_assert(dst->dir == MP_PIN_IN);
  ------------------
  |  |   41|   487k|#define mp_assert assert
  ------------------
  |  Branch (440:5): [True: 487k, False: 0]
  ------------------
  441|       |
  442|   487k|    if (dst->user_conn == src) {
  ------------------
  |  Branch (442:9): [True: 130k, False: 357k]
  ------------------
  443|   130k|        mp_assert(src->user_conn == dst);
  ------------------
  |  |   41|   130k|#define mp_assert assert
  ------------------
  |  Branch (443:9): [True: 130k, False: 0]
  ------------------
  444|   130k|        return;
  445|   130k|    }
  446|       |
  447|   357k|    mp_pin_disconnect(src);
  448|   357k|    mp_pin_disconnect(dst);
  449|       |
  450|   357k|    src->user_conn = dst;
  451|   357k|    dst->user_conn = src;
  452|       |
  453|   357k|    init_connection(src);
  454|   357k|}
mp_pin_set_manual_connection_for:
  462|   130k|{
  463|   130k|    if (p->manual_connection == f)
  ------------------
  |  Branch (463:9): [True: 130k, False: 0]
  ------------------
  464|   130k|        return;
  465|      0|    if (p->within_conn)
  ------------------
  |  Branch (465:9): [True: 0, False: 0]
  ------------------
  466|      0|        mp_pin_disconnect(p);
  467|      0|    p->manual_connection = f;
  468|      0|    init_connection(p);
  469|      0|}
mp_pin_disconnect:
  499|  2.99M|{
  500|  2.99M|    if (!mp_pin_is_connected(p))
  ------------------
  |  Branch (500:9): [True: 357k, False: 2.63M]
  ------------------
  501|   357k|        return;
  502|       |
  503|  2.63M|    p->manual_connection = NULL;
  504|       |
  505|  2.63M|    struct mp_pin *conn = p->user_conn;
  506|  2.63M|    if (conn) {
  ------------------
  |  Branch (506:9): [True: 357k, False: 2.27M]
  ------------------
  507|   357k|        p->user_conn = NULL;
  508|   357k|        conn->user_conn = NULL;
  509|   357k|        deinit_connection(conn);
  510|   357k|    }
  511|       |
  512|  2.63M|    deinit_connection(p);
  513|  2.63M|}
mp_pin_is_connected:
  516|  2.99M|{
  517|  2.99M|    return p->user_conn || p->manual_connection;
  ------------------
  |  Branch (517:12): [True: 357k, False: 2.63M]
  |  Branch (517:28): [True: 2.27M, False: 357k]
  ------------------
  518|  2.99M|}
mp_filter_get_named_pin:
  552|  1.13M|{
  553|  1.65M|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (553:21): [True: 520k, False: 1.13M]
  ------------------
  554|   520k|        if (name && strcmp(f->pins[n]->name, name) == 0)
  ------------------
  |  Branch (554:13): [True: 520k, False: 0]
  |  Branch (554:21): [True: 0, False: 520k]
  ------------------
  555|      0|            return f->pins[n];
  556|   520k|    }
  557|  1.13M|    return NULL;
  558|  1.13M|}
mp_filter_set_error_handler:
  561|  23.8M|{
  562|  23.8M|    f->in->error_handler = handler;
  563|  23.8M|}
mp_filter_has_failed:
  578|  23.8M|{
  579|  23.8M|    bool failed = filter->in->failed;
  580|       |    filter->in->failed = false;
  581|  23.8M|    return failed;
  582|  23.8M|}
mp_filter_reset:
  595|  32.5k|{
  596|  32.5k|    if (!filter)
  ------------------
  |  Branch (596:9): [True: 0, False: 32.5k]
  ------------------
  597|      0|        return;
  598|       |
  599|  32.5k|    for (int n = 0; n < filter->in->num_children; n++)
  ------------------
  |  Branch (599:21): [True: 0, False: 32.5k]
  ------------------
  600|      0|        mp_filter_reset(filter->in->children[n]);
  601|       |
  602|  32.5k|    for (int n = 0; n < filter->num_pins; n++) {
  ------------------
  |  Branch (602:21): [True: 0, False: 32.5k]
  ------------------
  603|      0|        struct mp_pin *p = filter->ppins[n];
  604|      0|        reset_pin(p);
  605|      0|        reset_pin(p->other);
  606|      0|    }
  607|       |
  608|  32.5k|    if (filter->in->info->reset)
  ------------------
  |  Branch (608:9): [True: 0, False: 32.5k]
  ------------------
  609|      0|        filter->in->info->reset(filter);
  610|  32.5k|}
mp_filter_add_pin:
  614|  1.13M|{
  615|  1.13M|    mp_assert(dir == MP_PIN_IN || dir == MP_PIN_OUT);
  ------------------
  |  |   41|  1.13M|#define mp_assert assert
  ------------------
  |  Branch (615:5): [True: 520k, False: 617k]
  |  Branch (615:5): [True: 617k, False: 0]
  ------------------
  616|  1.13M|    mp_assert(name && name[0]);
  ------------------
  |  |   41|  1.13M|#define mp_assert assert
  ------------------
  |  Branch (616:5): [True: 1.13M, False: 0]
  |  Branch (616:5): [True: 1.13M, False: 0]
  ------------------
  617|  1.13M|    mp_assert(!mp_filter_get_named_pin(f, name));
  ------------------
  |  |   41|  1.13M|#define mp_assert assert
  ------------------
  |  Branch (617:5): [True: 1.13M, False: 0]
  ------------------
  618|       |
  619|       |    // "Public" pin
  620|  1.13M|    struct mp_pin *p = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|  1.13M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.13M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.13M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|  1.13M|    *p = (struct mp_pin){
  622|  1.13M|        .name = talloc_strdup(p, name),
  ------------------
  |  |   50|  1.13M|#define talloc_strdup                   ta_xstrdup
  ------------------
  623|  1.13M|        .dir = dir,
  624|  1.13M|        .owner = f,
  625|  1.13M|        .manual_connection = f->in->parent,
  626|  1.13M|    };
  627|       |
  628|       |    // "Private" paired pin
  629|  1.13M|    p->other = talloc_ptrtype(NULL, p);
  ------------------
  |  |   34|  1.13M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  1.13M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  1.13M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|  1.13M|    *p->other = (struct mp_pin){
  631|  1.13M|        .name = p->name,
  632|  1.13M|        .dir = p->dir == MP_PIN_IN ? MP_PIN_OUT : MP_PIN_IN,
  ------------------
  |  Branch (632:16): [True: 520k, False: 617k]
  ------------------
  633|  1.13M|        .owner = f,
  634|  1.13M|        .other = p,
  635|  1.13M|        .manual_connection = f,
  636|  1.13M|    };
  637|       |
  638|  1.13M|    MP_TARRAY_GROW(f, f->pins, f->num_pins);
  ------------------
  |  |   96|  1.13M|    do {                                            \
  |  |   97|  1.13M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  1.13M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  1.13M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  1.13M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 617k, False: 520k]
  |  |  ------------------
  |  |   99|  1.13M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   617k|    do {                                                        \
  |  |  |  |   89|   617k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   617k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   617k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   617k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   617k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   617k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   617k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 617k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  1.13M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 1.13M]
  |  |  ------------------
  ------------------
  639|  1.13M|    MP_TARRAY_GROW(f, f->ppins, f->num_pins);
  ------------------
  |  |   96|  1.13M|    do {                                            \
  |  |   97|  1.13M|        size_t nextidx_ = (nextidx);                \
  |  |   98|  1.13M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  ------------------
  |  |  |  |   84|  1.13M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  ------------------
  |  |  |  |  |  |   45|  1.13M|#define talloc_get_size                 ta_get_size
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (98:13): [True: 617k, False: 520k]
  |  |  ------------------
  |  |   99|  1.13M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  ------------------
  |  |  |  |   88|   617k|    do {                                                        \
  |  |  |  |   89|   617k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|   617k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   617k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   617k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   617k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |   90|   617k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |   91|   617k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (91:14): [Folded, False: 617k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  100|  1.13M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (100:14): [Folded, False: 1.13M]
  |  |  ------------------
  ------------------
  640|  1.13M|    f->pins[f->num_pins] = p;
  641|  1.13M|    f->ppins[f->num_pins] = p->other;
  642|  1.13M|    f->num_pins += 1;
  643|       |
  644|  1.13M|    init_connection(p);
  645|       |
  646|  1.13M|    return p->other;
  647|  1.13M|}
mp_filter_remove_pin:
  650|  1.13M|{
  651|  1.13M|    if (!p)
  ------------------
  |  Branch (651:9): [True: 0, False: 1.13M]
  ------------------
  652|      0|        return;
  653|       |
  654|  1.13M|    mp_assert(p->owner == f);
  ------------------
  |  |   41|  1.13M|#define mp_assert assert
  ------------------
  |  Branch (654:5): [True: 1.13M, False: 0]
  ------------------
  655|  1.13M|    mp_pin_disconnect(p);
  656|  1.13M|    mp_pin_disconnect(p->other);
  657|       |
  658|  1.13M|    int index = -1;
  659|  1.13M|    for (int n = 0; n < f->num_pins; n++) {
  ------------------
  |  Branch (659:21): [True: 1.13M, False: 0]
  ------------------
  660|  1.13M|        if (f->ppins[n] == p) {
  ------------------
  |  Branch (660:13): [True: 1.13M, False: 0]
  ------------------
  661|  1.13M|            index = n;
  662|  1.13M|            break;
  663|  1.13M|        }
  664|  1.13M|    }
  665|  1.13M|    mp_assert(index >= 0);
  ------------------
  |  |   41|  1.13M|#define mp_assert assert
  ------------------
  |  Branch (665:5): [True: 1.13M, False: 0]
  ------------------
  666|       |
  667|  1.13M|    talloc_free(f->pins[index]);
  ------------------
  |  |   47|  1.13M|#define talloc_free                     ta_free
  ------------------
  668|  1.13M|    talloc_free(f->ppins[index]);
  ------------------
  |  |   47|  1.13M|#define talloc_free                     ta_free
  ------------------
  669|       |
  670|  1.13M|    int count = f->num_pins;
  671|  1.13M|    MP_TARRAY_REMOVE_AT(f->pins, count, index);
  ------------------
  |  |  143|  1.13M|    do {                                            \
  |  |  144|  1.13M|        size_t at_ = (at);                          \
  |  |  145|  1.13M|        assert(at_ < (idxvar));                     \
  |  |  146|  1.13M|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  1.13M|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  1.13M|        (idxvar)--;                                 \
  |  |  149|  1.13M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 1.13M]
  |  |  ------------------
  ------------------
  |  Branch (671:5): [True: 1.13M, False: 0]
  ------------------
  672|  1.13M|    count = f->num_pins;
  673|  1.13M|    MP_TARRAY_REMOVE_AT(f->ppins, count, index);
  ------------------
  |  |  143|  1.13M|    do {                                            \
  |  |  144|  1.13M|        size_t at_ = (at);                          \
  |  |  145|  1.13M|        assert(at_ < (idxvar));                     \
  |  |  146|  1.13M|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|  1.13M|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|  1.13M|        (idxvar)--;                                 \
  |  |  149|  1.13M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 1.13M]
  |  |  ------------------
  ------------------
  |  Branch (673:5): [True: 1.13M, False: 0]
  ------------------
  674|  1.13M|    f->num_pins -= 1;
  675|  1.13M|}
mp_filter_command:
  678|  5.91M|{
  679|  5.91M|    return f->in->info->command ? f->in->info->command(f, cmd) : false;
  ------------------
  |  Branch (679:12): [True: 3.38M, False: 2.53M]
  ------------------
  680|  5.91M|}
mp_filter_find_stream_info:
  683|   942k|{
  684|  2.86M|    while (f) {
  ------------------
  |  Branch (684:12): [True: 2.86M, False: 0]
  ------------------
  685|  2.86M|        if (f->stream_info)
  ------------------
  |  Branch (685:13): [True: 942k, False: 1.91M]
  ------------------
  686|   942k|            return f->stream_info;
  687|  1.91M|        f = f->in->parent;
  688|  1.91M|    }
  689|      0|    return NULL;
  690|   942k|}
mp_filter_wakeup:
  726|  65.0k|{
  727|       |    filter_wakeup(f, false);
  728|  65.0k|}
mp_filter_graph_set_max_run_time:
  736|  32.5k|{
  737|  32.5k|    struct filter_runner *r = f->in->runner;
  738|  32.5k|    mp_assert(f == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (738:5): [True: 32.5k, False: 0]
  ------------------
  739|  32.5k|    r->max_run_time = seconds;
  740|  32.5k|}
mp_filter_graph_interrupt:
  743|     87|{
  744|     87|    struct filter_runner *r = f->in->runner;
  745|     87|    mp_assert(f == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|     87|#define mp_assert assert
  ------------------
  |  Branch (745:5): [True: 87, False: 0]
  ------------------
  746|     87|    atomic_store(&r->interrupt_flag, true);
  747|     87|}
mp_filter_free_children:
  750|   910k|{
  751|  1.43M|    while(f->in->num_children)
  ------------------
  |  Branch (751:11): [True: 520k, False: 910k]
  ------------------
  752|   520k|        talloc_free(f->in->children[0]);
  ------------------
  |  |   47|   520k|#define talloc_free                     ta_free
  ------------------
  753|   910k|}
mp_filter_create_with_params:
  800|   650k|{
  801|   650k|    struct mp_filter *f = talloc(NULL, struct mp_filter);
  ------------------
  |  |   26|   650k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   650k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   650k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  802|   650k|    talloc_set_destructor(f, filter_destructor);
  ------------------
  |  |   41|   650k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  803|   650k|    *f = (struct mp_filter){
  804|   650k|        .priv = params->info->priv_size ?
  ------------------
  |  Branch (804:17): [True: 520k, False: 130k]
  ------------------
  805|   650k|                    talloc_zero_size(f, params->info->priv_size) : NULL,
  ------------------
  |  |   44|   520k|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|   520k|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   520k|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|   520k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|   520k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|   520k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|   650k|        .global = params->global,
  807|   650k|        .packet_pool = demux_packet_pool_get(params->parent ? params->parent->global : params->global),
  ------------------
  |  Branch (807:46): [True: 617k, False: 32.5k]
  ------------------
  808|   650k|        .in = talloc(f, struct mp_filter_internal),
  ------------------
  |  |   26|   650k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   650k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   650k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|   650k|    };
  810|   650k|    *f->in = (struct mp_filter_internal){
  811|   650k|        .info = params->info,
  812|   650k|        .parent = params->parent,
  813|   650k|        .runner = params->parent ? params->parent->in->runner : NULL,
  ------------------
  |  Branch (813:19): [True: 617k, False: 32.5k]
  ------------------
  814|   650k|    };
  815|       |
  816|   650k|    if (!f->in->runner) {
  ------------------
  |  Branch (816:9): [True: 32.5k, False: 617k]
  ------------------
  817|  32.5k|        mp_assert(params->global);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (817:9): [True: 32.5k, False: 0]
  ------------------
  818|       |
  819|  32.5k|        f->in->runner = talloc(NULL, struct filter_runner);
  ------------------
  |  |   26|  32.5k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  32.5k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  820|  32.5k|        *f->in->runner = (struct filter_runner){
  821|  32.5k|            .global = params->global,
  822|  32.5k|            .root_filter = f,
  823|  32.5k|            .max_run_time = INFINITY,
  824|  32.5k|        };
  825|  32.5k|        mp_mutex_init(&f->in->runner->async_lock);
  826|  32.5k|    }
  827|       |
  828|   650k|    if (!f->global)
  ------------------
  |  Branch (828:9): [True: 617k, False: 32.5k]
  ------------------
  829|   617k|        f->global = f->in->runner->global;
  830|       |
  831|   650k|    if (f->in->parent) {
  ------------------
  |  Branch (831:9): [True: 617k, False: 32.5k]
  ------------------
  832|   617k|        struct mp_filter_internal *parent = f->in->parent->in;
  833|   617k|        MP_TARRAY_APPEND(parent, parent->children, parent->num_children, f);
  ------------------
  |  |  105|   617k|    do {                                            \
  |  |  106|   617k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   617k|    do {                                            \
  |  |  |  |   97|   617k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   617k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   617k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   617k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 422k, False: 195k]
  |  |  |  |  ------------------
  |  |  |  |   99|   617k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   422k|    do {                                                        \
  |  |  |  |  |  |   89|   422k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   422k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   422k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   422k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   422k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   422k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   422k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 422k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   617k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 617k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   617k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   617k|        (idxvar)++;                                 \
  |  |  109|   617k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 617k]
  |  |  ------------------
  ------------------
  834|   617k|        f->log = mp_log_new(f, f->global->log, params->info->name);
  835|   617k|    } else {
  836|  32.5k|        f->log = mp_log_new(f, f->global->log, "!root");
  837|  32.5k|    }
  838|       |
  839|   650k|    if (f->in->info->init) {
  ------------------
  |  Branch (839:9): [True: 0, False: 650k]
  ------------------
  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|   650k|    return f;
  847|   650k|}
mp_filter_create:
  851|   617k|{
  852|   617k|    mp_assert(parent);
  ------------------
  |  |   41|   617k|#define mp_assert assert
  ------------------
  |  Branch (852:5): [True: 617k, False: 0]
  ------------------
  853|   617k|    mp_assert(info);
  ------------------
  |  |   41|   617k|#define mp_assert assert
  ------------------
  |  Branch (853:5): [True: 617k, False: 0]
  ------------------
  854|   617k|    struct mp_filter_params params = {
  855|   617k|        .info = info,
  856|   617k|        .parent = parent,
  857|   617k|    };
  858|   617k|    return mp_filter_create_with_params(&params);
  859|   617k|}
mp_filter_create_root:
  868|  32.5k|{
  869|  32.5k|    struct mp_filter_params params = {
  870|  32.5k|        .info = &filter_root,
  871|  32.5k|        .global = global,
  872|  32.5k|    };
  873|  32.5k|    return mp_filter_create_with_params(&params);
  874|  32.5k|}
mp_filter_graph_set_wakeup_cb:
  878|  32.5k|{
  879|  32.5k|    struct filter_runner *r = root->in->runner;
  880|  32.5k|    mp_assert(root == r->root_filter); // user is supposed to call this on root only
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (880:5): [True: 32.5k, False: 0]
  ------------------
  881|  32.5k|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  32.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  882|  32.5k|    r->wakeup_cb = wakeup_cb;
  883|  32.5k|    r->wakeup_ctx = ctx;
  884|  32.5k|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  32.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  885|  32.5k|}
filter.c:add_pending:
  131|  46.1M|{
  132|  46.1M|    struct filter_runner *r = f->in->runner;
  133|       |
  134|  46.1M|    if (f->in->pending)
  ------------------
  |  Branch (134:9): [True: 2.37M, False: 43.7M]
  ------------------
  135|  2.37M|        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|  43.7M|    f->in->pending = true;
  140|  43.7M|    if (f->in->high_priority) {
  ------------------
  |  Branch (140:9): [True: 0, False: 43.7M]
  ------------------
  141|      0|        MP_TARRAY_INSERT_AT(r, r->pending, r->num_pending, 0, f);
  ------------------
  |  |  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 (141:9): [True: 0, False: 0]
  ------------------
  142|  43.7M|    } else {
  143|  43.7M|        MP_TARRAY_APPEND(r, r->pending, r->num_pending, f);
  ------------------
  |  |  105|  43.7M|    do {                                            \
  |  |  106|  43.7M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  43.7M|    do {                                            \
  |  |  |  |   97|  43.7M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  43.7M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  43.7M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  43.7M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 130k, False: 43.6M]
  |  |  |  |  ------------------
  |  |  |  |   99|  43.7M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   130k|    do {                                                        \
  |  |  |  |  |  |   89|   130k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   130k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   130k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   130k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   130k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   130k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   130k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 130k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  43.7M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 43.7M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  43.7M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  43.7M|        (idxvar)++;                                 \
  |  |  109|  43.7M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 43.7M]
  |  |  ------------------
  ------------------
  144|  43.7M|    }
  145|  43.7M|}
filter.c:flush_async_notifications:
  199|  4.20M|{
  200|  4.20M|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  4.20M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  201|  4.27M|    for (int n = 0; n < r->num_async_pending; n++) {
  ------------------
  |  Branch (201:21): [True: 65.0k, False: 4.20M]
  ------------------
  202|  65.0k|        struct mp_filter *f = r->async_pending[n];
  203|  65.0k|        add_pending(f);
  204|  65.0k|        f->in->async_pending = false;
  205|  65.0k|    }
  206|  4.20M|    r->num_async_pending = 0;
  207|  4.20M|    r->async_wakeup_sent = false;
  208|  4.20M|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  4.20M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  209|  4.20M|}
filter.c:add_pending_pin:
  148|  42.2M|{
  149|  42.2M|    struct mp_filter *f = p->manual_connection;
  150|  42.2M|    mp_assert(f);
  ------------------
  |  |   41|  42.2M|#define mp_assert assert
  ------------------
  |  Branch (150:5): [True: 42.2M, False: 0]
  ------------------
  151|       |
  152|  42.2M|    if (f->in->pending)
  ------------------
  |  Branch (152:9): [True: 32.5k, False: 42.2M]
  ------------------
  153|  32.5k|        return;
  154|       |
  155|  42.2M|    add_pending(f);
  156|       |
  157|       |    // Need to tell user that something changed.
  158|  42.2M|    if (f == f->in->runner->root_filter && p != f->in->runner->recursive)
  ------------------
  |  Branch (158:9): [True: 845k, False: 41.3M]
  |  Branch (158:44): [True: 3.95k, False: 841k]
  ------------------
  159|  3.95k|        f->in->runner->external_pending = true;
  160|  42.2M|}
filter.c:filter_recursive:
  169|  55.8M|{
  170|  55.8M|    struct mp_filter *f = p->conn->manual_connection;
  171|  55.8M|    mp_assert(f);
  ------------------
  |  |   41|  55.8M|#define mp_assert assert
  ------------------
  |  Branch (171:5): [True: 55.8M, False: 0]
  ------------------
  172|  55.8M|    struct filter_runner *r = f->in->runner;
  173|       |
  174|       |    // Never do internal filtering recursively.
  175|  55.8M|    if (r->filtering)
  ------------------
  |  Branch (175:9): [True: 54.9M, False: 902k]
  ------------------
  176|  54.9M|        return;
  177|       |
  178|   902k|    mp_assert(!r->recursive);
  ------------------
  |  |   41|   902k|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 902k, False: 0]
  ------------------
  179|   902k|    r->recursive = p;
  180|       |
  181|       |    // Also don't lose the pending state, which the user may or may not
  182|       |    // care about.
  183|   902k|    r->external_pending |= mp_filter_graph_run(r->root_filter);
  184|       |
  185|   902k|    mp_assert(r->recursive == p);
  ------------------
  |  |   41|   902k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 902k, False: 0]
  ------------------
  186|   902k|    r->recursive = NULL;
  187|   902k|}
filter.c:init_connection:
  385|  1.49M|{
  386|  1.49M|    struct filter_runner *runner = p->owner->in->runner;
  387|       |
  388|  1.49M|    if (p->dir == MP_PIN_IN)
  ------------------
  |  Branch (388:9): [True: 520k, False: 975k]
  ------------------
  389|   520k|        p = p->other;
  390|       |
  391|  1.49M|    struct mp_pin *in = find_connected_end(p);
  392|  1.49M|    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.49M|    mp_assert(!in->user_conn);
  ------------------
  |  |   41|  1.49M|#define mp_assert assert
  ------------------
  |  Branch (395:5): [True: 1.49M, False: 0]
  ------------------
  396|  1.49M|    mp_assert(!out->user_conn);
  ------------------
  |  |   41|  1.49M|#define mp_assert assert
  ------------------
  |  Branch (396:5): [True: 1.49M, False: 0]
  ------------------
  397|       |
  398|       |    // This and similar checks enforce the same root filter requirement.
  399|  1.49M|    if (in->manual_connection)
  ------------------
  |  Branch (399:9): [True: 1.49M, False: 0]
  ------------------
  400|  1.49M|        mp_assert(in->manual_connection->in->runner == runner);
  ------------------
  |  |   41|  1.49M|#define mp_assert assert
  ------------------
  |  Branch (400:9): [True: 1.49M, False: 0]
  ------------------
  401|  1.49M|    if (out->manual_connection)
  ------------------
  |  Branch (401:9): [True: 1.49M, False: 0]
  ------------------
  402|  1.49M|        mp_assert(out->manual_connection->in->runner == runner);
  ------------------
  |  |   41|  1.49M|#define mp_assert assert
  ------------------
  |  Branch (402:9): [True: 1.49M, 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.49M|    if (!in->manual_connection || !out->manual_connection)
  ------------------
  |  Branch (408:9): [True: 0, False: 1.49M]
  |  Branch (408:35): [True: 0, False: 1.49M]
  ------------------
  409|      0|        return;
  410|       |
  411|  1.49M|    mp_assert(in->dir == MP_PIN_IN);
  ------------------
  |  |   41|  1.49M|#define mp_assert assert
  ------------------
  |  Branch (411:5): [True: 1.49M, False: 0]
  ------------------
  412|  1.49M|    mp_assert(out->dir == MP_PIN_OUT);
  ------------------
  |  |   41|  1.49M|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 1.49M, False: 0]
  ------------------
  413|       |
  414|  1.49M|    struct mp_pin *cur = in;
  415|  3.38M|    while (cur) {
  ------------------
  |  Branch (415:12): [True: 1.88M, False: 1.49M]
  ------------------
  416|  1.88M|        mp_assert(!cur->within_conn && !cur->other->within_conn);
  ------------------
  |  |   41|  1.88M|#define mp_assert assert
  ------------------
  |  Branch (416:9): [True: 1.88M, False: 0]
  |  Branch (416:9): [True: 1.88M, False: 0]
  ------------------
  417|  1.88M|        mp_assert(!cur->conn && !cur->other->conn);
  ------------------
  |  |   41|  1.88M|#define mp_assert assert
  ------------------
  |  Branch (417:9): [True: 1.88M, False: 0]
  |  Branch (417:9): [True: 1.88M, False: 0]
  ------------------
  418|  1.88M|        mp_assert(!cur->data_requested); // unused for in pins
  ------------------
  |  |   41|  1.88M|#define mp_assert assert
  ------------------
  |  Branch (418:9): [True: 1.88M, False: 0]
  ------------------
  419|  1.88M|        mp_assert(!cur->data.type); // unused for in pins
  ------------------
  |  |   41|  1.88M|#define mp_assert assert
  ------------------
  |  Branch (419:9): [True: 1.88M, False: 0]
  ------------------
  420|  1.88M|        mp_assert(!cur->other->data_requested); // unset for unconnected out pins
  ------------------
  |  |   41|  1.88M|#define mp_assert assert
  ------------------
  |  Branch (420:9): [True: 1.88M, False: 0]
  ------------------
  421|  1.88M|        mp_assert(!cur->other->data.type); // unset for unconnected out pins
  ------------------
  |  |   41|  1.88M|#define mp_assert assert
  ------------------
  |  Branch (421:9): [True: 1.88M, False: 0]
  ------------------
  422|  1.88M|        mp_assert(cur->owner->in->runner == runner);
  ------------------
  |  |   41|  1.88M|#define mp_assert assert
  ------------------
  |  Branch (422:9): [True: 1.88M, False: 0]
  ------------------
  423|  1.88M|        cur->within_conn = cur->other->within_conn = true;
  424|  1.88M|        cur = cur->other->user_conn;
  425|  1.88M|    }
  426|       |
  427|  1.49M|    in->conn = out;
  428|  1.49M|    in->within_conn = false;
  429|  1.49M|    out->conn = in;
  430|  1.49M|    out->within_conn = false;
  431|       |
  432|       |    // Scheduling so far will be messed up.
  433|  1.49M|    add_pending(in->manual_connection);
  434|  1.49M|    add_pending(out->manual_connection);
  435|  1.49M|}
filter.c:find_connected_end:
  372|  5.98M|{
  373|  6.63M|    while (1) {
  ------------------
  |  Branch (373:12): [True: 6.63M, Folded]
  ------------------
  374|  6.63M|        struct mp_pin *other = p->other;
  375|  6.63M|        if (!other->user_conn)
  ------------------
  |  Branch (375:13): [True: 5.98M, False: 650k]
  ------------------
  376|  5.98M|            return other;
  377|   650k|        p = other->user_conn;
  378|   650k|    }
  379|      0|    MP_ASSERT_UNREACHABLE();
  ------------------
  |  |   46|      0|#define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort())
  ------------------
  |  Branch (379:5): [Folded, False: 0]
  ------------------
  380|      0|}
filter.c:deinit_connection:
  477|  2.99M|{
  478|  2.99M|    if (p->dir == MP_PIN_OUT)
  ------------------
  |  Branch (478:9): [True: 1.49M, False: 1.49M]
  ------------------
  479|  1.49M|        p = p->other;
  480|       |
  481|  2.99M|    p = find_connected_end(p);
  482|       |
  483|  6.30M|    while (p) {
  ------------------
  |  Branch (483:12): [True: 3.31M, False: 2.99M]
  ------------------
  484|  3.31M|        p->conn = p->other->conn = NULL;
  485|  3.31M|        p->within_conn = p->other->within_conn = false;
  486|  3.31M|        mp_assert(!p->other->data_requested); // unused for in pins
  ------------------
  |  |   41|  3.31M|#define mp_assert assert
  ------------------
  |  Branch (486:9): [True: 3.31M, False: 0]
  ------------------
  487|  3.31M|        mp_assert(!p->other->data.type); // unused for in pins
  ------------------
  |  |   41|  3.31M|#define mp_assert assert
  ------------------
  |  Branch (487:9): [True: 3.31M, False: 0]
  ------------------
  488|  3.31M|        if (p->data.type)
  ------------------
  |  Branch (488:13): [True: 0, False: 3.31M]
  ------------------
  489|  3.31M|            MP_VERBOSE(p->owner, "dropping frame due to pin disconnect\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  490|  3.31M|        if (p->data_requested)
  ------------------
  |  Branch (490:13): [True: 0, False: 3.31M]
  ------------------
  491|  3.31M|            MP_VERBOSE(p->owner, "dropping request due to pin disconnect\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  492|       |        p->data_requested = false;
  493|  3.31M|        mp_frame_unref(&p->data);
  494|  3.31M|        p = p->other->user_conn;
  495|  3.31M|    }
  496|  2.99M|}
filter.c:filter_wakeup:
  709|  65.0k|{
  710|  65.0k|    struct filter_runner *r = f->in->runner;
  711|  65.0k|    mp_mutex_lock(&r->async_lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  712|  65.0k|    if (!f->in->async_pending) {
  ------------------
  |  Branch (712:9): [True: 65.0k, False: 0]
  ------------------
  713|  65.0k|        f->in->async_pending = true;
  714|       |        // (not using a talloc parent for thread safety reasons)
  715|  65.0k|        MP_TARRAY_APPEND(NULL, r->async_pending, r->num_async_pending, f);
  ------------------
  |  |  105|  65.0k|    do {                                            \
  |  |  106|  65.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  65.0k|    do {                                            \
  |  |  |  |   97|  65.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  65.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  65.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  65.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 32.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  65.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  65.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 65.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  65.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  65.0k|        (idxvar)++;                                 \
  |  |  109|  65.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 65.0k]
  |  |  ------------------
  ------------------
  716|  65.0k|    }
  717|  65.0k|    if (!mark_only && !r->async_wakeup_sent) {
  ------------------
  |  Branch (717:9): [True: 65.0k, False: 0]
  |  Branch (717:23): [True: 65.0k, False: 0]
  ------------------
  718|  65.0k|        if (r->wakeup_cb)
  ------------------
  |  Branch (718:13): [True: 65.0k, False: 0]
  ------------------
  719|  65.0k|            r->wakeup_cb(r->wakeup_ctx);
  720|  65.0k|        r->async_wakeup_sent = true;
  721|  65.0k|    }
  722|  65.0k|    mp_mutex_unlock(&r->async_lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  723|  65.0k|}
filter.c:filter_destructor:
  756|   650k|{
  757|   650k|    struct mp_filter *f = p;
  758|   650k|    struct filter_runner *r = f->in->runner;
  759|       |
  760|   650k|    if (f->in->info->destroy)
  ------------------
  |  Branch (760:9): [True: 552k, False: 97.5k]
  ------------------
  761|   552k|        f->in->info->destroy(f);
  762|       |
  763|       |    // For convenience, free child filters.
  764|   650k|    mp_filter_free_children(f);
  765|       |
  766|  1.78M|    while (f->num_pins)
  ------------------
  |  Branch (766:12): [True: 1.13M, False: 650k]
  ------------------
  767|  1.13M|        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|   650k|    flush_async_notifications(r);
  772|       |
  773|   650k|    for (int n = 0; n < r->num_pending; n++) {
  ------------------
  |  Branch (773:21): [True: 0, False: 650k]
  ------------------
  774|      0|        if (r->pending[n] == f) {
  ------------------
  |  Branch (774:13): [True: 0, False: 0]
  ------------------
  775|      0|            MP_TARRAY_REMOVE_AT(r->pending, r->num_pending, 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 (775:13): [True: 0, False: 0]
  ------------------
  776|      0|            break;
  777|      0|        }
  778|      0|    }
  779|       |
  780|   650k|    if (f->in->parent) {
  ------------------
  |  Branch (780:9): [True: 617k, False: 32.5k]
  ------------------
  781|   617k|        struct mp_filter_internal *p_in = f->in->parent->in;
  782|   845k|        for (int n = 0; n < p_in->num_children; n++) {
  ------------------
  |  Branch (782:25): [True: 845k, False: 0]
  ------------------
  783|   845k|            if (p_in->children[n] == f) {
  ------------------
  |  Branch (783:17): [True: 617k, False: 227k]
  ------------------
  784|   617k|                MP_TARRAY_REMOVE_AT(p_in->children, p_in->num_children, n);
  ------------------
  |  |  143|   617k|    do {                                            \
  |  |  144|   617k|        size_t at_ = (at);                          \
  |  |  145|   617k|        assert(at_ < (idxvar));                     \
  |  |  146|   617k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   617k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   617k|        (idxvar)--;                                 \
  |  |  149|   617k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 617k]
  |  |  ------------------
  ------------------
  |  Branch (784:17): [True: 617k, False: 0]
  ------------------
  785|   617k|                break;
  786|   617k|            }
  787|   845k|        }
  788|   617k|    }
  789|       |
  790|   650k|    if (r->root_filter == f) {
  ------------------
  |  Branch (790:9): [True: 32.5k, False: 617k]
  ------------------
  791|  32.5k|        mp_assert(!f->in->parent);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (791:9): [True: 32.5k, False: 0]
  ------------------
  792|  32.5k|        mp_mutex_destroy(&r->async_lock);
  ------------------
  |  |  133|  32.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  793|  32.5k|        talloc_free(r->async_pending);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  794|  32.5k|        talloc_free(r);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  795|  32.5k|    }
  796|   650k|}

mp_frame_is_signaling:
  137|  3.38M|{
  138|  3.38M|    return frame_handlers[frame.type].is_signaling;
  139|  3.38M|}
mp_frame_unref:
  142|  3.57M|{
  143|  3.57M|    if (!frame)
  ------------------
  |  Branch (143:9): [True: 0, False: 3.57M]
  ------------------
  144|      0|        return;
  145|       |
  146|  3.57M|    if (frame_handlers[frame->type].free)
  ------------------
  |  Branch (146:9): [True: 0, False: 3.57M]
  ------------------
  147|      0|        frame_handlers[frame->type].free(frame->data);
  148|       |
  149|  3.57M|    *frame = (struct mp_frame){0};
  150|  3.57M|}
mp_frame_get_pts:
  164|  12.6M|{
  165|  12.6M|    if (frame_handlers[frame.type].get_pts)
  ------------------
  |  Branch (165:9): [True: 12.1M, False: 455k]
  ------------------
  166|  12.1M|        return frame_handlers[frame.type].get_pts(frame.data);
  167|   455k|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|   455k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  12.6M|}
frame.c:video_get_pts:
   29|  12.1M|{
   30|  12.1M|    return ((struct mp_image *)data)->pts;
   31|  12.1M|}

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

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

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

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

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

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

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

bstrcmp:
   31|  62.5M|{
   32|  62.5M|    int ret = 0;
   33|  62.5M|    if (str1.len && str2.len)
  ------------------
  |  Branch (33:9): [True: 62.5M, False: 0]
  |  Branch (33:21): [True: 62.4M, False: 32.5k]
  ------------------
   34|  62.4M|        ret = memcmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|  62.4M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 22.2M, False: 40.2M]
  |  |  ------------------
  ------------------
   35|       |
   36|  62.5M|    if (!ret) {
  ------------------
  |  Branch (36:9): [True: 9.36M, False: 53.1M]
  ------------------
   37|  9.36M|        if (str1.len == str2.len)
  ------------------
  |  Branch (37:13): [True: 7.77M, False: 1.59M]
  ------------------
   38|  7.77M|            return 0;
   39|  1.59M|        else if (str1.len > str2.len)
  ------------------
  |  Branch (39:18): [True: 162k, False: 1.43M]
  ------------------
   40|   162k|            return 1;
   41|  1.43M|        else
   42|  1.43M|            return -1;
   43|  9.36M|    }
   44|  53.1M|    return ret;
   45|  62.5M|}
bstrcasecmp:
   48|  1.68M|{
   49|  1.68M|    int ret = 0;
   50|  1.68M|    if (str1.len && str2.len)
  ------------------
  |  Branch (50:9): [True: 1.45M, False: 232k]
  |  Branch (50:21): [True: 1.45M, False: 229]
  ------------------
   51|  1.45M|        ret = strncasecmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
  ------------------
  |  |   45|  1.45M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 484k, False: 972k]
  |  |  ------------------
  ------------------
   52|       |
   53|  1.68M|    if (!ret) {
  ------------------
  |  Branch (53:9): [True: 499k, False: 1.19M]
  ------------------
   54|   499k|        if (str1.len == str2.len)
  ------------------
  |  Branch (54:13): [True: 232k, False: 266k]
  ------------------
   55|   232k|            return 0;
   56|   266k|        else if (str1.len > str2.len)
  ------------------
  |  Branch (56:18): [True: 665, False: 265k]
  ------------------
   57|    665|            return 1;
   58|   265k|        else
   59|   265k|            return -1;
   60|   499k|    }
   61|  1.19M|    return ret;
   62|  1.68M|}
bstrchr:
   65|  20.7M|{
   66|  20.7M|    if (!str.len)
  ------------------
  |  Branch (66:9): [True: 2, False: 20.7M]
  ------------------
   67|      2|        return -1;
   68|  20.7M|    unsigned char *pos = memchr(str.start, c, str.len);
   69|  20.7M|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (69:12): [True: 17.2M, False: 3.48M]
  ------------------
   70|  20.7M|}
bstrrchr:
   73|  9.69M|{
   74|  9.69M|    if (!str.len)
  ------------------
  |  Branch (74:9): [True: 0, False: 9.69M]
  ------------------
   75|      0|        return -1;
   76|  9.69M|#if HAVE_MEMRCHR
   77|  9.69M|    unsigned char *pos = memrchr(str.start, c, str.len);
   78|  9.69M|    return pos ? pos - str.start : -1;
  ------------------
  |  Branch (78:12): [True: 9.46M, False: 231k]
  ------------------
   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|  9.69M|}
bstrcspn:
   88|  2.90M|{
   89|  2.90M|    int i;
   90|  38.5M|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (90:17): [True: 38.4M, False: 104k]
  ------------------
   91|  38.4M|        if (strchr(reject, str.start[i]))
  ------------------
  |  Branch (91:13): [True: 2.79M, False: 35.6M]
  ------------------
   92|  2.79M|            break;
   93|  2.90M|    return i;
   94|  2.90M|}
bstrspn:
   97|   321k|{
   98|   321k|    int i;
   99|   939k|    for (i = 0; i < str.len; i++)
  ------------------
  |  Branch (99:17): [True: 776k, False: 162k]
  ------------------
  100|   776k|        if (!strchr(accept, str.start[i]))
  ------------------
  |  Branch (100:13): [True: 159k, False: 617k]
  ------------------
  101|   159k|            break;
  102|   321k|    return i;
  103|   321k|}
bstr_find:
  106|  10.9M|{
  107|  50.7M|    for (int i = 0; i < haystack.len; i++)
  ------------------
  |  Branch (107:21): [True: 49.0M, False: 1.69M]
  ------------------
  108|  49.0M|        if (bstr_startswith(bstr_splice(haystack, i, haystack.len), needle))
  ------------------
  |  Branch (108:13): [True: 9.24M, False: 39.8M]
  ------------------
  109|  9.24M|            return i;
  110|  1.69M|    return -1;
  111|  10.9M|}
bstr_lstrip:
  114|  12.5M|{
  115|  12.6M|    while (str.len && mp_isspace(*str.start)) {
  ------------------
  |  Branch (115:12): [True: 9.68M, False: 2.96M]
  |  Branch (115:23): [True: 92.3k, False: 9.59M]
  ------------------
  116|  92.3k|        str.start++;
  117|  92.3k|        str.len--;
  118|  92.3k|    }
  119|  12.5M|    return str;
  120|  12.5M|}
bstr_strip:
  123|  2.22M|{
  124|  2.22M|    str = bstr_lstrip(str);
  125|  4.11M|    while (str.len && mp_isspace(str.start[str.len - 1]))
  ------------------
  |  Branch (125:12): [True: 4.03M, False: 75.3k]
  |  Branch (125:23): [True: 1.88M, False: 2.14M]
  ------------------
  126|  1.88M|        str.len--;
  127|  2.22M|    return str;
  128|  2.22M|}
bstr_split:
  131|  71.9k|{
  132|  71.9k|    int start;
  133|  71.9k|    for (start = 0; start < str.len; start++)
  ------------------
  |  Branch (133:21): [True: 71.9k, False: 0]
  ------------------
  134|  71.9k|        if (!strchr(sep, str.start[start]))
  ------------------
  |  Branch (134:13): [True: 71.9k, False: 0]
  ------------------
  135|  71.9k|            break;
  136|  71.9k|    str = bstr_cut(str, start);
  137|  71.9k|    int end = bstrcspn(str, sep);
  138|  71.9k|    if (rest) {
  ------------------
  |  Branch (138:9): [True: 0, False: 71.9k]
  ------------------
  139|      0|        *rest = bstr_cut(str, end);
  140|      0|    }
  141|  71.9k|    return bstr_splice(str, 0, end);
  142|  71.9k|}
bstr_split_tok:
  148|  2.24M|{
  149|  2.24M|    bstr bsep = bstr0(tok);
  150|  2.24M|    int pos = bstr_find(str, bsep);
  151|  2.24M|    if (pos < 0)
  ------------------
  |  Branch (151:9): [True: 1.69M, False: 552k]
  ------------------
  152|  1.69M|        pos = str.len;
  153|  2.24M|    *out_left = bstr_splice(str, 0, pos);
  154|  2.24M|    *out_right = bstr_cut(str, pos + bsep.len);
  155|  2.24M|    return pos != str.len;
  156|  2.24M|}
bstr_splice:
  159|  85.6M|{
  160|  85.6M|    if (!str.len)
  ------------------
  |  Branch (160:9): [True: 2, False: 85.6M]
  ------------------
  161|      2|        return str;
  162|       |
  163|  85.6M|    if (start < 0)
  ------------------
  |  Branch (163:9): [True: 0, False: 85.6M]
  ------------------
  164|      0|        start += str.len;
  165|  85.6M|    if (end < 0)
  ------------------
  |  Branch (165:9): [True: 0, False: 85.6M]
  ------------------
  166|      0|        end += str.len;
  167|  85.6M|    end = MPMIN(end, str.len);
  ------------------
  |  |   45|  85.6M|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 1.69M, False: 83.9M]
  |  |  ------------------
  ------------------
  168|  85.6M|    start = MPMAX(start, 0);
  ------------------
  |  |   44|  85.6M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 46.7M, False: 38.8M]
  |  |  ------------------
  ------------------
  169|  85.6M|    end = MPMAX(end, start);
  ------------------
  |  |   44|  85.6M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 85.1M, False: 440k]
  |  |  ------------------
  ------------------
  170|  85.6M|    str.start += start;
  171|  85.6M|    str.len = end - start;
  172|  85.6M|    return str;
  173|  85.6M|}
bstrtoll:
  176|  65.0k|{
  177|  65.0k|    str = bstr_lstrip(str);
  178|  65.0k|    char buf[51];
  179|  65.0k|    int len = MPMIN(str.len, 50);
  ------------------
  |  |   45|  65.0k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 65.0k]
  |  |  ------------------
  ------------------
  180|  65.0k|    memcpy(buf, str.start, len);
  181|  65.0k|    buf[len] = 0;
  182|  65.0k|    char *endptr;
  183|  65.0k|    long long r = strtoll(buf, &endptr, base);
  184|  65.0k|    if (rest)
  ------------------
  |  Branch (184:9): [True: 65.0k, False: 0]
  ------------------
  185|  65.0k|        *rest = bstr_cut(str, endptr - buf);
  186|  65.0k|    return r;
  187|  65.0k|}
bstrtod:
  190|   357k|{
  191|   357k|    str = bstr_lstrip(str);
  192|   357k|    char buf[101];
  193|   357k|    int len = MPMIN(str.len, 100);
  ------------------
  |  |   45|   357k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 357k]
  |  |  ------------------
  ------------------
  194|   357k|    memcpy(buf, str.start, len);
  195|   357k|    buf[len] = 0;
  196|   357k|    char *endptr;
  197|   357k|    double r = strtod(buf, &endptr);
  198|   357k|    if (rest)
  ------------------
  |  Branch (198:9): [True: 357k, False: 0]
  ------------------
  199|   357k|        *rest = bstr_cut(str, endptr - buf);
  200|   357k|    return r;
  201|   357k|}
bstr_splitchar:
  204|  17.9M|{
  205|  17.9M|    int pos = bstrchr(str, c);
  206|  17.9M|    if (pos < 0)
  ------------------
  |  Branch (206:9): [True: 1.53M, False: 16.4M]
  ------------------
  207|  1.53M|        pos = str.len;
  208|  17.9M|    if (rest)
  ------------------
  |  Branch (208:9): [True: 17.9M, False: 0]
  ------------------
  209|  17.9M|        *rest = bstr_cut(str, pos + 1);
  210|  17.9M|    return bstr_splice(str, 0, pos + 1);
  211|  17.9M|}
bstr_strip_linebreaks:
  214|  3.34M|{
  215|  3.34M|    if (bstr_endswith0(str, "\r\n")) {
  ------------------
  |  Branch (215:9): [True: 1.25k, False: 3.34M]
  ------------------
  216|  1.25k|        str = bstr_splice(str, 0, str.len - 2);
  217|  3.34M|    } else if (bstr_endswith0(str, "\n")) {
  ------------------
  |  Branch (217:16): [True: 3.32M, False: 16.3k]
  ------------------
  218|  3.32M|        str = bstr_splice(str, 0, str.len - 1);
  219|  3.32M|    }
  220|  3.34M|    return str;
  221|  3.34M|}
bstr_eatstart:
  224|  73.7M|{
  225|  73.7M|    if (!bstr_startswith(*s, prefix))
  ------------------
  |  Branch (225:9): [True: 64.8M, False: 8.83M]
  ------------------
  226|  64.8M|        return false;
  227|  8.83M|    *s = bstr_cut(*s, prefix.len);
  228|       |    return true;
  229|  73.7M|}
bstr_eatend:
  232|      2|{
  233|      2|    if (!bstr_endswith(*s, prefix))
  ------------------
  |  Branch (233:9): [True: 2, False: 0]
  ------------------
  234|      2|        return false;
  235|      0|    s->len -= prefix.len;
  236|       |    return true;
  237|      2|}
bstr_parse_utf8_code_length:
  257|   732M|{
  258|   732M|    if (b < 128)
  ------------------
  |  Branch (258:9): [True: 730M, False: 2.22M]
  ------------------
  259|   730M|        return 1;
  260|  2.22M|    int bytes = 7 - mp_log2(b ^ 255);
  261|  2.22M|    return (bytes >= 2 && bytes <= 4) ? bytes : -1;
  ------------------
  |  Branch (261:13): [True: 1.83M, False: 394k]
  |  Branch (261:27): [True: 1.51M, False: 314k]
  ------------------
  262|   732M|}
bstr_decode_partial_utf8:
  265|  3.77M|{
  266|  3.77M|    if (s->len == 0)
  ------------------
  |  Branch (266:9): [True: 0, False: 3.77M]
  ------------------
  267|      0|        return -1;
  268|  3.77M|    unsigned int codepoint = s->start[0];
  269|  3.77M|    s->start++; s->len--;
  270|  3.77M|    if (codepoint >= 128) {
  ------------------
  |  Branch (270:9): [True: 862k, False: 2.91M]
  ------------------
  271|   862k|        int bytes = bstr_parse_utf8_code_length(codepoint);
  272|   862k|        if (bytes < 1)
  ------------------
  |  Branch (272:13): [True: 343k, False: 518k]
  ------------------
  273|   343k|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|   343k|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  274|   518k|        codepoint &= 127 >> bytes;
  275|   603k|        for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (275:25): [True: 559k, False: 44.2k]
  ------------------
  276|   559k|            if (!s->len)
  ------------------
  |  Branch (276:17): [True: 2.44k, False: 556k]
  ------------------
  277|  2.44k|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|  2.44k|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  278|   556k|            int tmp = (unsigned char)s->start[0];
  279|   556k|            if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (279:17): [True: 472k, False: 84.5k]
  ------------------
  280|   472k|                return BSTR_DECODE_TRUNCATED_SEQUENCE;
  ------------------
  |  |   92|   472k|#define BSTR_DECODE_TRUNCATED_SEQUENCE -2
  ------------------
  281|  84.5k|            codepoint = (codepoint << 6) | (tmp & ~0xC0);
  282|  84.5k|            s->start++; s->len--;
  283|  84.5k|        }
  284|  44.2k|        if (codepoint > 0x10FFFF || (codepoint >= 0xD800 && codepoint <= 0xDFFF))
  ------------------
  |  Branch (284:13): [True: 538, False: 43.6k]
  |  Branch (284:38): [True: 9.94k, False: 33.7k]
  |  Branch (284:61): [True: 353, False: 9.59k]
  ------------------
  285|    891|            return BSTR_DECODE_OUT_OF_RANGE;
  ------------------
  |  |   91|    891|#define BSTR_DECODE_OUT_OF_RANGE -1
  ------------------
  286|       |
  287|       |        // Overlong sequences - check taken from libavcodec.
  288|  43.3k|        unsigned int min = bytes == 2 ? 0x80 : 1 << (5 * bytes - 4);
  ------------------
  |  Branch (288:28): [True: 25.3k, False: 17.9k]
  ------------------
  289|  43.3k|        if (codepoint < min)
  ------------------
  |  Branch (289:13): [True: 1.05k, False: 42.2k]
  ------------------
  290|  1.05k|            return BSTR_DECODE_OVERLONG_ENCODING;
  ------------------
  |  |   93|  1.05k|#define BSTR_DECODE_OVERLONG_ENCODING -3
  ------------------
  291|  43.3k|    }
  292|  2.95M|    return codepoint;
  293|  3.77M|}
bstr_decode_utf8:
  296|  3.77M|{
  297|  3.77M|    int res = bstr_decode_partial_utf8(&s);
  298|  3.77M|    if (res >= 0 && out_next)
  ------------------
  |  Branch (298:9): [True: 2.95M, False: 819k]
  |  Branch (298:21): [True: 2.95M, False: 0]
  ------------------
  299|  2.95M|        *out_next = s;
  300|  3.77M|    return res;
  301|  3.77M|}
bstr_validate_utf8:
  315|   171k|{
  316|  1.54M|    while (s.len) {
  ------------------
  |  Branch (316:12): [True: 1.39M, False: 143k]
  ------------------
  317|  1.39M|        if (bstr_decode_utf8(s, &s) < 0) {
  ------------------
  |  Branch (317:13): [True: 28.1k, False: 1.36M]
  ------------------
  318|       |            // Try to guess whether the sequence was just cut-off.
  319|  28.1k|            unsigned int codepoint = (unsigned char)s.start[0];
  320|  28.1k|            int bytes = bstr_parse_utf8_code_length(codepoint);
  321|  28.1k|            if (bytes > 1 && s.len < 6) {
  ------------------
  |  Branch (321:17): [True: 6.38k, False: 21.7k]
  |  Branch (321:30): [True: 2.82k, False: 3.55k]
  ------------------
  322|       |                // Manually check validity of left bytes
  323|  3.36k|                for (int n = 1; n < bytes; n++) {
  ------------------
  |  Branch (323:33): [True: 3.24k, False: 123]
  ------------------
  324|  3.24k|                    if (n >= s.len) {
  ------------------
  |  Branch (324:25): [True: 1.02k, False: 2.22k]
  ------------------
  325|       |                        // Everything valid until now - just cut off.
  326|  1.02k|                        return -(bytes - s.len);
  327|  1.02k|                    }
  328|  2.22k|                    int tmp = (unsigned char)s.start[n];
  329|  2.22k|                    if ((tmp & 0xC0) != 0x80)
  ------------------
  |  Branch (329:25): [True: 1.68k, False: 539]
  ------------------
  330|  1.68k|                        break;
  331|  2.22k|                }
  332|  2.82k|            }
  333|  27.1k|            return -8;
  334|  28.1k|        }
  335|  1.39M|    }
  336|   143k|    return 0;
  337|   171k|}
bstr_sanitize_utf8_latin1:
  340|  5.23k|{
  341|  5.23k|    bstr new = {0};
  342|  5.23k|    bstr left = s;
  343|  5.23k|    unsigned char *first_ok = s.start;
  344|  2.33M|    while (left.len) {
  ------------------
  |  Branch (344:12): [True: 2.33M, False: 5.23k]
  ------------------
  345|  2.33M|        int r = bstr_decode_utf8(left, &left);
  346|  2.33M|        if (r < 0) {
  ------------------
  |  Branch (346:13): [True: 777k, False: 1.55M]
  ------------------
  347|   777k|            bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  348|   777k|            mp_append_utf8_bstr(talloc_ctx, &new, (unsigned char)left.start[0]);
  349|   777k|            left.start += 1;
  350|   777k|            left.len -= 1;
  351|   777k|            first_ok = left.start;
  352|   777k|        }
  353|  2.33M|    }
  354|  5.23k|    if (!new.start)
  ------------------
  |  Branch (354:9): [True: 398, False: 4.83k]
  ------------------
  355|    398|        return s;
  356|  4.83k|    if (first_ok != left.start)
  ------------------
  |  Branch (356:9): [True: 2.27k, False: 2.56k]
  ------------------
  357|  2.27k|        bstr_xappend(talloc_ctx, &new, (bstr){first_ok, left.start - first_ok});
  358|  4.83k|    return new;
  359|  5.23k|}
bstr_xappend:
  375|  5.30M|{
  376|  5.30M|    if (!append.len)
  ------------------
  |  Branch (376:9): [True: 649k, False: 4.65M]
  ------------------
  377|   649k|        return;
  378|  4.65M|    resize_append(talloc_ctx, s, append.len + 1);
  379|  4.65M|    memmove(s->start + s->len, append.start, append.len);
  380|  4.65M|    s->len += append.len;
  381|  4.65M|    s->start[s->len] = '\0';
  382|  4.65M|}
bstr_xappend_asprintf:
  385|   632k|{
  386|   632k|    va_list ap;
  387|   632k|    va_start(ap, fmt);
  388|   632k|    int ret = bstr_xappend_vasprintf(talloc_ctx, s, fmt, ap);
  389|       |    va_end(ap);
  390|   632k|    return ret;
  391|   632k|}
bstr_xappend_vasprintf:
  395|  18.5M|{
  396|  18.5M|    int size;
  397|  18.5M|    va_list copy;
  398|  18.5M|    va_copy(copy, ap);
  399|  18.5M|    size_t avail = talloc_get_size(s->start) - s->len;
  ------------------
  |  |   45|  18.5M|#define talloc_get_size                 ta_get_size
  ------------------
  400|  18.5M|    char *dest = s->start ? s->start + s->len : NULL;
  ------------------
  |  Branch (400:18): [True: 18.4M, False: 137k]
  ------------------
  401|  18.5M|    size = vsnprintf(dest, avail, fmt, copy);
  402|  18.5M|    va_end(copy);
  403|       |
  404|  18.5M|    if (size < 0)
  ------------------
  |  Branch (404:9): [True: 0, False: 18.5M]
  ------------------
  405|      0|        return size;
  406|       |
  407|  18.5M|    if (avail < 1 || size + 1 > avail) {
  ------------------
  |  Branch (407:9): [True: 137k, False: 18.4M]
  |  Branch (407:22): [True: 310k, False: 18.0M]
  ------------------
  408|   447k|        resize_append(talloc_ctx, s, size + 1);
  409|   447k|        vsnprintf(s->start + s->len, size + 1, fmt, ap);
  410|   447k|    }
  411|  18.5M|    s->len += size;
  412|  18.5M|    return size;
  413|  18.5M|}
bstr_case_startswith:
  416|   604k|{
  417|   604k|    struct bstr start = bstr_splice(s, 0, prefix.len);
  418|   604k|    return start.len == prefix.len && bstrcasecmp(start, prefix) == 0;
  ------------------
  |  Branch (418:12): [True: 446k, False: 157k]
  |  Branch (418:39): [True: 215, False: 446k]
  ------------------
  419|   604k|}
bstr_find_in_list0:
  465|   200k|{
  466|   600k|    for (int n = 0; list && list[n]; n++)
  ------------------
  |  Branch (466:21): [True: 600k, False: 0]
  |  Branch (466:29): [True: 600k, False: 0]
  ------------------
  467|   600k|        if (case_sensitive ? !bstrcmp0(str, list[n]) : !bstrcasecmp0(str, list[n]))
  ------------------
  |  Branch (467:13): [True: 0, False: 600k]
  |  Branch (467:13): [True: 200k, False: 400k]
  ------------------
  468|   200k|            return n;
  469|       |
  470|      0|    return -1;
  471|   200k|}
bstr_in_list0:
  474|   200k|{
  475|       |    return bstr_find_in_list0(str, list, false) != -1;
  476|   200k|}
bstr.c:resize_append:
  362|  5.10M|{
  363|  5.10M|    size_t size = talloc_get_size(s->start);
  ------------------
  |  |   45|  5.10M|#define talloc_get_size                 ta_get_size
  ------------------
  364|  5.10M|    mp_assert(s->len <= size);
  ------------------
  |  |   41|  5.10M|#define mp_assert assert
  ------------------
  |  Branch (364:5): [True: 5.10M, False: 0]
  ------------------
  365|  5.10M|    if (append_min > size - s->len) {
  ------------------
  |  Branch (365:9): [True: 1.19M, False: 3.90M]
  ------------------
  366|  1.19M|        if (append_min < size)
  ------------------
  |  Branch (366:13): [True: 157k, False: 1.03M]
  ------------------
  367|   157k|            append_min = size; // preallocate in power of 2s
  368|  1.19M|        if (size >= SIZE_MAX / 2 || append_min >= SIZE_MAX / 2)
  ------------------
  |  Branch (368:13): [True: 0, False: 1.19M]
  |  Branch (368:37): [True: 0, False: 1.19M]
  ------------------
  369|      0|            abort(); // oom
  370|  1.19M|        s->start = talloc_realloc_size(talloc_ctx, s->start, size + append_min);
  ------------------
  |  |   39|  1.19M|#define talloc_realloc_size             ta_xrealloc_size
  |  |  ------------------
  |  |  |  |  158|  1.19M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.19M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  1.19M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  1.19M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|  1.19M|    }
  372|  5.10M|}

client.c:bstr0:
   62|   390k|{
   63|   390k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 390k, False: 0]
  ------------------
   64|   390k|}
command.c:bstr0:
   62|  9.20M|{
   63|  9.20M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 9.20M, False: 0]
  ------------------
   64|  9.20M|}
configfiles.c:bstr0:
   62|  65.0k|{
   63|  65.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 65.0k, False: 0]
  ------------------
   64|  65.0k|}
loadfile.c:bstr0:
   62|  53.5k|{
   63|  53.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 53.5k, False: 0]
  ------------------
   64|  53.5k|}
loadfile.c:bstrdup0:
   40|  7.02k|{
   41|  7.02k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  7.02k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  7.02k|}
main.c:bstr0:
   62|  32.5k|{
   63|  32.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32.5k, False: 0]
  ------------------
   64|  32.5k|}
misc.c:bstr0:
   62|  86.0k|{
   63|  86.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 86.0k, False: 0]
  ------------------
   64|  86.0k|}
misc.c:bstr_xappend0:
  180|  86.0k|{
  181|  86.0k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|  86.0k|}
misc.c:bstrto0:
   46|  39.5k|{
   47|  39.5k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 39.5k, False: 0]
  ------------------
   48|  39.5k|}
misc.c:bstrdup0:
   40|  39.5k|{
   41|  39.5k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  39.5k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  39.5k|}
scripting.c:bstr0:
   62|  32.5k|{
   63|  32.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32.5k, False: 0]
  ------------------
   64|  32.5k|}
stream.c:bstr0:
   62|   197k|{
   63|   197k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 197k, False: 0]
  ------------------
   64|   197k|}
stream.c:bstr_startswith0:
  246|   164k|{
  247|   164k|    return bstr_startswith(str, bstr0(prefix));
  248|   164k|}
stream.c:bstr_startswith:
  239|   164k|{
  240|   164k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 1.54k, False: 163k]
  ------------------
  241|  1.54k|        return false;
  242|   163k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   164k|}
stream_file.c:bstrcasecmp0:
  281|  65.0k|{
  282|  65.0k|    return bstrcasecmp(str1, bstr0(str2));
  283|  65.0k|}
stream_file.c:bstr0:
   62|  97.5k|{
   63|  97.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 97.5k, False: 0]
  ------------------
   64|  97.5k|}
stream_memory.c:bstr0:
   62|   173k|{
   63|   173k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 173k, False: 0]
  ------------------
   64|   173k|}
stream_memory.c:bstr_eatstart0:
  291|   115k|{
  292|   115k|    return bstr_eatstart(s, bstr0(prefix));
  293|   115k|}
stream_memory.c:bstrdup:
   52|  57.6k|{
   53|  57.6k|    struct bstr r = { NULL, str.len };
   54|  57.6k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 57.6k, False: 0]
  ------------------
   55|  57.6k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  57.6k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  57.6k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  57.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  57.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  57.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  57.6k|    return r;
   57|  57.6k|}
sd_ass.c:bstr_cut:
  227|   499k|{
  228|   499k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 499k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|   499k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 499k]
  ------------------
  234|      0|        n = str.len;
  235|   499k|    return (struct bstr){str.start + n, str.len - n};
  236|   499k|}
vo.c:bstr0:
   62|  32.5k|{
   63|  32.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32.5k, False: 0]
  ------------------
   64|  32.5k|}
codecs.c:bstr0:
   62|  32.5k|{
   63|  32.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 0, False: 32.5k]
  ------------------
   64|  32.5k|}
msg.c:bstr_eatstart0:
  291|  13.1M|{
  292|  13.1M|    return bstr_eatstart(s, bstr0(prefix));
  293|  13.1M|}
msg.c:bstr0:
   62|  13.1M|{
   63|  13.1M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 13.1M, False: 0]
  ------------------
   64|  13.1M|}
msg.c:bstr_getline:
  156|  14.6M|{
  157|  14.6M|    return bstr_splitchar(str, rest, '\n');
  158|  14.6M|}
msg.c:bstrdup0:
   40|  1.23M|{
   41|  1.23M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.23M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.23M|}
playlist.c:bstr0:
   62|  32.5k|{
   63|  32.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32.5k, False: 0]
  ------------------
   64|  32.5k|}
tags.c:bstr0:
   62|  26.0M|{
   63|  26.0M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 26.0M, False: 0]
  ------------------
   64|  26.0M|}
tags.c:bstrcasecmp0:
  281|   232k|{
  282|   232k|    return bstrcasecmp(str1, bstr0(str2));
  283|   232k|}
tags.c:bstrto0:
   46|  51.7k|{
   47|  51.7k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 51.7k, False: 0]
  ------------------
   48|  51.7k|}
tags.c:bstrdup0:
   40|  51.7k|{
   41|  51.7k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  51.7k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  51.7k|}
demux.c:bstr_xappend0:
  180|  39.5k|{
  181|  39.5k|    bstr_xappend(talloc_ctx, s, bstr0(append));
  182|  39.5k|}
demux.c:bstr0:
   62|   101k|{
   63|   101k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 101k, False: 0]
  ------------------
   64|   101k|}
demux_lavf.c:bstrcasecmp0:
  281|   217k|{
  282|   217k|    return bstrcasecmp(str1, bstr0(str2));
  283|   217k|}
demux_lavf.c:bstr0:
   62|   379k|{
   63|   379k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 379k, False: 0]
  ------------------
   64|   379k|}
demux_lavf.c:bstr_endswith0:
  258|  45.3k|{
  259|  45.3k|    return bstr_endswith(str, bstr0(suffix));
  260|  45.3k|}
demux_lavf.c:bstr_endswith:
  251|  45.3k|{
  252|  45.3k|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 6.01k, False: 39.2k]
  ------------------
  253|  6.01k|        return false;
  254|  39.2k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  45.3k|}
demux_null.c:bstr_startswith0:
  246|  15.0k|{
  247|  15.0k|    return bstr_startswith(str, bstr0(prefix));
  248|  15.0k|}
demux_null.c:bstr_startswith:
  239|  15.0k|{
  240|  15.0k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 0, False: 15.0k]
  ------------------
  241|      0|        return false;
  242|  15.0k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  15.0k|}
demux_null.c:bstr0:
   62|  30.0k|{
   63|  30.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 30.0k, False: 0]
  ------------------
   64|  30.0k|}
demux_playlist.c:bstr_equals0:
  276|  45.0k|{
  277|  45.0k|    return bstr_equals(str1, bstr0(str2));
  278|  45.0k|}
demux_playlist.c:bstr_equals:
  268|  45.0k|{
  269|  45.0k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 44.4k, False: 582]
  ------------------
  270|  44.4k|        return false;
  271|       |
  272|    582|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 582]
  |  Branch (272:40): [True: 0, False: 582]
  ------------------
  273|  45.0k|}
demux_playlist.c:bstr0:
   62|   401k|{
   63|   401k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 379k, False: 22.0k]
  ------------------
   64|   401k|}
demux_playlist.c:bstrcasecmp0:
  281|  30.0k|{
  282|  30.0k|    return bstrcasecmp(str1, bstr0(str2));
  283|  30.0k|}
user_filters.c:bstr0:
   62|  32.5k|{
   63|  32.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32.5k, False: 0]
  ------------------
   64|  32.5k|}
cmd.c:bstr_equals0:
  276|  1.17M|{
  277|  1.17M|    return bstr_equals(str1, bstr0(str2));
  278|  1.17M|}
cmd.c:bstr_equals:
  268|  1.17M|{
  269|  1.17M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 1.07M, False: 97.5k]
  ------------------
  270|  1.07M|        return false;
  271|       |
  272|  97.5k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 97.5k]
  |  Branch (272:40): [True: 0, False: 97.5k]
  ------------------
  273|  1.17M|}
cmd.c:bstr0:
   62|  1.39M|{
   63|  1.39M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.39M, False: 0]
  ------------------
   64|  1.39M|}
input.c:bstrdup:
   52|  32.5k|{
   53|  32.5k|    struct bstr r = { NULL, str.len };
   54|  32.5k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 32.5k, False: 0]
  ------------------
   55|  32.5k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  32.5k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  32.5k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  32.5k|    return r;
   57|  32.5k|}
input.c:bstr0:
   62|   130k|{
   63|   130k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 97.5k, False: 32.5k]
  ------------------
   64|   130k|}
input.c:bstr_equals:
  268|  32.5k|{
  269|  32.5k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 0, False: 32.5k]
  ------------------
  270|      0|        return false;
  271|       |
  272|  32.5k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 32.5k, False: 0]
  |  Branch (272:40): [True: 0, False: 0]
  ------------------
  273|  32.5k|}
bstr.c:bstr_startswith:
  239|   122M|{
  240|   122M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 6.22M, False: 116M]
  ------------------
  241|  6.22M|        return false;
  242|   116M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   122M|}
bstr.c:bstr_cut:
  227|  29.5M|{
  228|  29.5M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 29.5M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  29.5M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 3.22M, False: 26.3M]
  ------------------
  234|  3.22M|        n = str.len;
  235|  29.5M|    return (struct bstr){str.start + n, str.len - n};
  236|  29.5M|}
bstr.c:bstr0:
   62|  9.52M|{
   63|  9.52M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 9.52M, False: 0]
  ------------------
   64|  9.52M|}
bstr.c:bstr_endswith0:
  258|  6.68M|{
  259|  6.68M|    return bstr_endswith(str, bstr0(suffix));
  260|  6.68M|}
bstr.c:bstr_endswith:
  251|  6.68M|{
  252|  6.68M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 440k, False: 6.24M]
  ------------------
  253|   440k|        return false;
  254|  6.24M|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  6.68M|}
bstr.c:bstrcasecmp0:
  281|   600k|{
  282|   600k|    return bstrcasecmp(str1, bstr0(str2));
  283|   600k|}
charset_conv.c:bstr0:
   62|   522k|{
   63|   522k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 522k, False: 0]
  ------------------
   64|   522k|}
charset_conv.c:bstr_startswith0:
  246|   514k|{
  247|   514k|    return bstr_startswith(str, bstr0(prefix));
  248|   514k|}
charset_conv.c:bstr_startswith:
  239|   514k|{
  240|   514k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 425k, False: 89.2k]
  ------------------
  241|   425k|        return false;
  242|  89.2k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   514k|}
json.c:bstr0:
   62|   780k|{
   63|   780k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 585k, False: 195k]
  ------------------
   64|   780k|}
node.c:bstr0:
   62|  32.5k|{
   63|  32.5k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 32.5k, False: 0]
  ------------------
   64|  32.5k|}
node.c:bstrdup0:
   40|  32.5k|{
   41|  32.5k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  32.5k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  32.5k|}
path_utils.c:bstr0:
   62|  17.2M|{
   63|  17.2M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 17.2M, False: 0]
  ------------------
   64|  17.2M|}
path_utils.c:bstrdup0:
   40|  65.0k|{
   41|  65.0k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  65.0k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  65.0k|}
path_utils.c:bstr_find0:
  286|  8.68M|{
  287|  8.68M|    return bstr_find(haystack, bstr0(needle));
  288|  8.68M|}
m_config_frontend.c:bstr0:
   62|   181M|{
   63|   181M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 181M, False: 0]
  ------------------
   64|   181M|}
m_config_frontend.c:bstrcmp0:
  263|  35.2M|{
  264|  35.2M|    return bstrcmp(str1, bstr0(str2));
  265|  35.2M|}
m_config_frontend.c:bstr_eatstart0:
  291|   390k|{
  292|   390k|    return bstr_eatstart(s, bstr0(prefix));
  293|   390k|}
m_config_frontend.c:bstr_startswith:
  239|   134M|{
  240|   134M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 93.4M, False: 40.6M]
  ------------------
  241|  93.4M|        return false;
  242|  40.6M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|   134M|}
m_config_frontend.c:bstr_endswith:
  251|   455k|{
  252|   455k|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 0, False: 455k]
  ------------------
  253|      0|        return false;
  254|   455k|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|   455k|}
m_config_frontend.c:bstr_equals0:
  276|  10.3M|{
  277|  10.3M|    return bstr_equals(str1, bstr0(str2));
  278|  10.3M|}
m_config_frontend.c:bstr_equals:
  268|  10.3M|{
  269|  10.3M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 9.46M, False: 910k]
  ------------------
  270|  9.46M|        return false;
  271|       |
  272|   910k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 32.5k, False: 877k]
  |  Branch (272:40): [True: 65.0k, False: 812k]
  ------------------
  273|  10.3M|}
m_config_frontend.c:bstrto0:
   46|  3.83M|{
   47|  3.83M|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 3.83M, False: 0]
  ------------------
   48|  3.83M|}
m_config_frontend.c:bstrdup0:
   40|  3.83M|{
   41|  3.83M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  3.83M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  3.83M|}
m_option.c:bstr_equals0:
  276|  5.30M|{
  277|  5.30M|    return bstr_equals(str1, bstr0(str2));
  278|  5.30M|}
m_option.c:bstr_equals:
  268|  5.33M|{
  269|  5.33M|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 3.86M, False: 1.46M]
  ------------------
  270|  3.86M|        return false;
  271|       |
  272|  1.46M|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 292k, False: 1.17M]
  |  Branch (272:40): [True: 942k, False: 227k]
  ------------------
  273|  5.33M|}
m_option.c:bstr0:
   62|  14.1M|{
   63|  14.1M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 14.1M, False: 65.0k]
  ------------------
   64|  14.1M|}
m_option.c:bstrcasecmp0:
  281|  97.5k|{
  282|  97.5k|    return bstrcasecmp(str1, bstr0(str2));
  283|  97.5k|}
m_option.c:bstrcmp0:
  263|  2.27M|{
  264|  2.27M|    return bstrcmp(str1, bstr0(str2));
  265|  2.27M|}
m_option.c:bstr_eatstart0:
  291|  2.89M|{
  292|  2.89M|    return bstr_eatstart(s, bstr0(prefix));
  293|  2.89M|}
m_option.c:bstrdup0:
   40|  1.00M|{
   41|  1.00M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  1.00M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  1.00M|}
m_option.c:bstr_endswith0:
  258|  3.15M|{
  259|  3.15M|    return bstr_endswith(str, bstr0(suffix));
  260|  3.15M|}
m_option.c:bstr_endswith:
  251|  3.15M|{
  252|  3.15M|    if (str.len < suffix.len)
  ------------------
  |  Branch (252:9): [True: 1.30M, False: 1.85M]
  ------------------
  253|  1.30M|        return false;
  254|  1.85M|    return !memcmp(str.start + str.len - suffix.len, suffix.start, suffix.len);
  255|  3.15M|}
m_option.c:bstr_cut:
  227|   747k|{
  228|   747k|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 747k]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|   747k|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 97.5k, False: 650k]
  ------------------
  234|  97.5k|        n = str.len;
  235|   747k|    return (struct bstr){str.start + n, str.len - n};
  236|   747k|}
m_option.c:bstrdup:
   52|  97.5k|{
   53|  97.5k|    struct bstr r = { NULL, str.len };
   54|  97.5k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 97.5k, False: 0]
  ------------------
   55|  97.5k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  97.5k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  97.5k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  97.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  97.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  97.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  97.5k|    return r;
   57|  97.5k|}
m_option.c:bstrto0:
   46|   682k|{
   47|   682k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 682k, False: 0]
  ------------------
   48|   682k|}
m_property.c:bstrcmp0:
  263|  22.8M|{
  264|  22.8M|    return bstrcmp(str1, bstr0(str2));
  265|  22.8M|}
m_property.c:bstr0:
   62|  88.7M|{
   63|  88.7M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 88.7M, False: 0]
  ------------------
   64|  88.7M|}
m_property.c:bstr_eatstart0:
  291|  48.1M|{
  292|  48.1M|    return bstr_eatstart(s, bstr0(prefix));
  293|  48.1M|}
m_property.c:bstr_startswith0:
  246|  13.5M|{
  247|  13.5M|    return bstr_startswith(str, bstr0(prefix));
  248|  13.5M|}
m_property.c:bstr_startswith:
  239|  13.5M|{
  240|  13.5M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 845k, False: 12.6M]
  ------------------
  241|   845k|        return false;
  242|  12.6M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  13.5M|}
m_property.c:bstr_cut:
  227|  16.0M|{
  228|  16.0M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 16.0M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  16.0M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 16.0M]
  ------------------
  234|      0|        n = str.len;
  235|  16.0M|    return (struct bstr){str.start + n, str.len - n};
  236|  16.0M|}
m_property.c:bstrdup0:
   40|  2.53M|{
   41|  2.53M|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  2.53M|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  2.53M|}
parse_configfile.c:bstr_eatstart0:
  291|  8.74M|{
  292|  8.74M|    return bstr_eatstart(s, bstr0(prefix));
  293|  8.74M|}
parse_configfile.c:bstr0:
   62|  18.6M|{
   63|  18.6M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 18.6M, False: 0]
  ------------------
   64|  18.6M|}
parse_configfile.c:bstr_getline:
  156|  3.28M|{
  157|  3.28M|    return bstr_splitchar(str, rest, '\n');
  158|  3.28M|}
parse_configfile.c:bstr_startswith0:
  246|  9.91M|{
  247|  9.91M|    return bstr_startswith(str, bstr0(prefix));
  248|  9.91M|}
parse_configfile.c:bstr_startswith:
  239|  9.91M|{
  240|  9.91M|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 2.89M, False: 7.02M]
  ------------------
  241|  2.89M|        return false;
  242|  7.02M|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  9.91M|}
parse_configfile.c:bstrto0:
   46|   390k|{
   47|   390k|    return str.start ? bstrdup0(talloc_ctx, str) : talloc_strdup(talloc_ctx, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  |  Branch (47:12): [True: 390k, False: 0]
  ------------------
   48|   390k|}
parse_configfile.c:bstrdup0:
   40|   390k|{
   41|   390k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|   390k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|   390k|}
parse_configfile.c:bstr_cut:
  227|  25.9M|{
  228|  25.9M|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 25.9M]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|  25.9M|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 25.9M]
  ------------------
  234|      0|        n = str.len;
  235|  25.9M|    return (struct bstr){str.start + n, str.len - n};
  236|  25.9M|}
path.c:bstr0:
   62|  1.50M|{
   63|  1.50M|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 1.44M, False: 65.0k]
  ------------------
   64|  1.50M|}
path.c:bstr_eatstart0:
  291|   234k|{
  292|   234k|    return bstr_eatstart(s, bstr0(prefix));
  293|   234k|}
path.c:bstr_equals0:
  276|   130k|{
  277|   130k|    return bstr_equals(str1, bstr0(str2));
  278|   130k|}
path.c:bstr_equals:
  268|   130k|{
  269|   130k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 130k, False: 0]
  ------------------
  270|   130k|        return false;
  271|       |
  272|      0|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 0]
  |  Branch (272:40): [True: 0, False: 0]
  ------------------
  273|   130k|}
external_files.c:bstr0:
   62|  65.0k|{
   63|  65.0k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 65.0k, False: 0]
  ------------------
   64|  65.0k|}
external_files.c:bstrdup:
   52|  32.5k|{
   53|  32.5k|    struct bstr r = { NULL, str.len };
   54|  32.5k|    if (str.start)
  ------------------
  |  Branch (54:9): [True: 32.5k, False: 0]
  ------------------
   55|  32.5k|        r.start = (unsigned char *)talloc_memdup(talloc_ctx, str.start, str.len);
  ------------------
  |  |   49|  32.5k|#define talloc_memdup                   ta_xmemdup
  |  |  ------------------
  |  |  |  |  157|  32.5k|#define ta_xmemdup(...)         ta_dbg_set_loc(ta_xmemdup(__VA_ARGS__), TA_LOC)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  32.5k|    return r;
   57|  32.5k|}
external_files.c:bstrdup0:
   40|  32.5k|{
   41|  32.5k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  32.5k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  32.5k|}
filter_sdh.c:bstrdup0:
   40|  51.2k|{
   41|  51.2k|    return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
  ------------------
  |  |   51|  51.2k|#define talloc_strndup                  ta_xstrndup
  ------------------
   42|  51.2k|}
vd_lavc.c:bstr0:
   62|   390k|{
   63|   390k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 390k, False: 0]
  ------------------
   64|   390k|}
vd_lavc.c:bstr_equals0:
  276|   357k|{
  277|   357k|    return bstr_equals(str1, bstr0(str2));
  278|   357k|}
vd_lavc.c:bstr_equals:
  268|   357k|{
  269|   357k|    if (str1.len != str2.len)
  ------------------
  |  Branch (269:9): [True: 325k, False: 32.5k]
  ------------------
  270|   325k|        return false;
  271|       |
  272|  32.5k|    return str1.start == str2.start || bstrcmp(str1, str2) == 0;
  ------------------
  |  Branch (272:12): [True: 0, False: 32.5k]
  |  Branch (272:40): [True: 32.5k, False: 0]
  ------------------
  273|   357k|}
cue.c:bstr_startswith0:
  246|  40.0k|{
  247|  40.0k|    return bstr_startswith(str, bstr0(prefix));
  248|  40.0k|}
cue.c:bstr_startswith:
  239|  40.0k|{
  240|  40.0k|    if (str.len < prefix.len)
  ------------------
  |  Branch (240:9): [True: 482, False: 39.5k]
  ------------------
  241|    482|        return false;
  242|  39.5k|    return !memcmp(str.start, prefix.start, prefix.len);
  243|  40.0k|}
cue.c:bstr_cut:
  227|    219|{
  228|    219|    if (n < 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 219]
  ------------------
  229|      0|        n += str.len;
  230|      0|        if (n < 0)
  ------------------
  |  Branch (230:13): [True: 0, False: 0]
  ------------------
  231|      0|            n = 0;
  232|      0|    }
  233|    219|    if (((size_t)n) > str.len)
  ------------------
  |  Branch (233:9): [True: 0, False: 219]
  ------------------
  234|      0|        n = str.len;
  235|    219|    return (struct bstr){str.start + n, str.len - n};
  236|    219|}
cue.c:bstr_getline:
  156|  59.2k|{
  157|  59.2k|    return bstr_splitchar(str, rest, '\n');
  158|  59.2k|}
cue.c:bstr0:
   62|   639k|{
   63|   639k|    return (struct bstr){(unsigned char *)s, s ? strlen(s) : 0};
  ------------------
  |  Branch (63:46): [True: 639k, False: 0]
  ------------------
   64|   639k|}
cue.c:bstr_eatstart0:
  291|     13|{
  292|     13|    return bstr_eatstart(s, bstr0(prefix));
  293|     13|}
cue.c:bstr_eatend0:
  296|      2|{
  297|      2|    return bstr_eatend(s, bstr0(prefix));
  298|      2|}

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

client.c:mp_isalnum:
   14|   227k|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 227k, False: 0]
  |  Branch (14:64): [True: 0, False: 0]
  ------------------
client.c:mp_isalpha:
   13|   227k|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 227k]
  |  Branch (13:64): [True: 227k, False: 0]
  ------------------
client.c:mp_isupper:
   10|   227k|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 227k, False: 0]
  |  Branch (10:59): [True: 0, False: 227k]
  ------------------
client.c:mp_islower:
   11|   227k|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 227k, False: 0]
  |  Branch (11:59): [True: 227k, False: 0]
  ------------------
bstr.c:mp_isspace:
    8|  13.7M|static inline int mp_isspace(char c) { return c == ' ' || c == '\f' || c == '\n' ||
  ------------------
  |  Branch (8:47): [True: 1.87M, False: 11.8M]
  |  Branch (8:59): [True: 1.42k, False: 11.8M]
  |  Branch (8:72): [True: 0, False: 11.8M]
  ------------------
    9|  11.8M|                                              c == '\r' || c == '\t' || c =='\v'; }
  ------------------
  |  Branch (9:47): [True: 89.6k, False: 11.7M]
  |  Branch (9:60): [True: 4.02k, False: 11.7M]
  |  Branch (9:73): [True: 3.89k, False: 11.7M]
  ------------------
path_utils.c:mp_isalpha:
   13|  26.0M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 26.0M]
  |  Branch (13:64): [True: 26.0M, False: 0]
  ------------------
path_utils.c:mp_isupper:
   10|  26.0M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 26.0M, False: 0]
  |  Branch (10:59): [True: 0, False: 26.0M]
  ------------------
path_utils.c:mp_islower:
   11|  26.0M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 26.0M, False: 0]
  |  Branch (11:59): [True: 26.0M, False: 0]
  ------------------
path_utils.c:mp_isalnum:
   14|  17.3M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 17.3M, False: 0]
  |  Branch (14:64): [True: 0, False: 0]
  ------------------
parse_configfile.c:mp_isalnum:
   14|  27.9M|static inline int mp_isalnum(char c) { return mp_isalpha(c) || mp_isdigit(c); }
  ------------------
  |  Branch (14:47): [True: 23.6M, False: 4.32M]
  |  Branch (14:64): [True: 0, False: 4.32M]
  ------------------
parse_configfile.c:mp_isalpha:
   13|  27.9M|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 0, False: 27.9M]
  |  Branch (13:64): [True: 23.6M, False: 4.32M]
  ------------------
parse_configfile.c:mp_isupper:
   10|  27.9M|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 23.6M, False: 4.32M]
  |  Branch (10:59): [True: 0, False: 23.6M]
  ------------------
parse_configfile.c:mp_islower:
   11|  27.9M|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 23.6M, False: 4.32M]
  |  Branch (11:59): [True: 23.6M, False: 0]
  ------------------
parse_configfile.c:mp_isdigit:
   12|  4.32M|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 2.08M, False: 2.24M]
  |  Branch (12:59): [True: 0, False: 2.08M]
  ------------------
filter_sdh.c:mp_isalpha:
   13|   115k|static inline int mp_isalpha(char c) { return mp_isupper(c) || mp_islower(c); }
  ------------------
  |  Branch (13:47): [True: 24.2k, False: 91.7k]
  |  Branch (13:64): [True: 5.28k, False: 86.4k]
  ------------------
filter_sdh.c:mp_islower:
   11|  91.7k|static inline int mp_islower(char c) { return c >= 'a' && c <= 'z'; }
  ------------------
  |  Branch (11:47): [True: 11.7k, False: 79.9k]
  |  Branch (11:59): [True: 5.28k, False: 6.45k]
  ------------------
filter_sdh.c:mp_isupper:
   10|   145k|static inline int mp_isupper(char c) { return c >= 'A' && c <= 'Z'; }
  ------------------
  |  Branch (10:47): [True: 73.3k, False: 72.1k]
  |  Branch (10:59): [True: 48.4k, False: 24.8k]
  ------------------
filter_sdh.c:mp_isdigit:
   12|   100k|static inline int mp_isdigit(char c) { return c >= '0' && c <= '9'; }
  ------------------
  |  Branch (12:47): [True: 31.2k, False: 69.4k]
  |  Branch (12:59): [True: 6.29k, False: 24.9k]
  ------------------

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

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

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

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

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

mp_basename_bstr:
   43|  8.69M|{
   44|  8.69M|    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|  8.69M|    separator_pos = bstrrchr(path, '/');
   57|  8.69M|    if (separator_pos < 0)
  ------------------
  |  Branch (57:9): [True: 72.0k, False: 8.62M]
  ------------------
   58|  72.0k|        return path;
   59|  8.62M|    return bstr_splice(path, separator_pos + 1, path.len);
   60|  8.69M|}
mp_basename:
   63|  8.53M|{
   64|  8.53M|    return mp_basename_bstr(bstr0(path)).start;
   65|  8.53M|}
mp_dirname:
   68|  32.5k|{
   69|  32.5k|    struct bstr ret = {
   70|  32.5k|        (uint8_t *)path, mp_basename(path) - path
   71|  32.5k|    };
   72|  32.5k|    if (ret.len == 0)
  ------------------
  |  Branch (72:9): [True: 0, False: 32.5k]
  ------------------
   73|      0|        return bstr0(".");
   74|  32.5k|    return ret;
   75|  32.5k|}
mp_strip_ext:
  114|  39.5k|{
  115|  39.5k|    bstr root = {0};
  116|  39.5k|    split_ext(path, &root);
  117|  39.5k|    return root.len ? root : path;
  ------------------
  |  Branch (117:12): [True: 0, False: 39.5k]
  ------------------
  118|  39.5k|}
mp_get_ext:
  121|   119k|{
  122|       |    return split_ext(path, NULL);
  123|   119k|}
mp_path_join_bstr:
  143|  65.0k|{
  144|  65.0k|    if (p1.len == 0)
  ------------------
  |  Branch (144:9): [True: 65.0k, False: 0]
  ------------------
  145|  65.0k|        return bstrdup0(talloc_ctx, p2);
  146|      0|    if (p2.len == 0)
  ------------------
  |  Branch (146:9): [True: 0, False: 0]
  ------------------
  147|      0|        return bstrdup0(talloc_ctx, p1);
  148|       |
  149|      0|    if (mp_path_is_absolute(p2))
  ------------------
  |  Branch (149:9): [True: 0, False: 0]
  ------------------
  150|      0|        return bstrdup0(talloc_ctx, p2);
  151|       |
  152|      0|    bool have_separator = strchr(mp_path_separators, p1.start[p1.len - 1]);
  153|       |#if HAVE_DOS_PATHS
  154|       |    // "X:" only => path relative to "X:" current working directory.
  155|       |    if (p1.len == 2 && p1.start[1] == ':')
  156|       |        have_separator = true;
  157|       |#endif
  158|       |
  159|      0|    return talloc_asprintf(talloc_ctx, "%.*s%s%.*s", BSTR_P(p1),
  ------------------
  |  |   52|      0|#define talloc_asprintf                 ta_xasprintf
  |  |  ------------------
  |  |  |  |  127|      0|#define ta_xasprintf(...)               ta_oom_s(ta_asprintf(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:62): [True: 0, False: 0]
  |  |  |  |  |  Branch (127:62): [True: 0, False: 0]
  |  |  |  |  |  Branch (127:62): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|      0|                           have_separator ? "" : "/", BSTR_P(p2));
  161|      0|}
mp_normalize_path:
  191|  39.5k|{
  192|  39.5k|    if (!path)
  ------------------
  |  Branch (192:9): [True: 0, False: 39.5k]
  ------------------
  193|      0|        return NULL;
  194|       |
  195|  39.5k|    if (!path[0] || mp_is_url(bstr0(path)) || !strcmp(path, "-"))
  ------------------
  |  Branch (195:9): [True: 0, False: 39.5k]
  |  Branch (195:21): [True: 39.5k, False: 0]
  |  Branch (195:47): [True: 0, False: 0]
  ------------------
  196|  39.5k|        return talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|  39.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  197|       |
  198|      0|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|      0|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      0|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  199|      0|    char *result;
  200|       |
  201|       |#if HAVE_DOS_PATHS
  202|       |    wchar_t *pathw = mp_from_utf8(tmp, path);
  203|       |    DWORD len = GetFullPathNameW(pathw, 0, NULL, NULL);
  204|       |    wchar_t *pathc = talloc_array(tmp, wchar_t, len);
  205|       |    if (!len || !GetFullPathNameW(pathw, len, pathc, NULL)) {
  206|       |        result = talloc_strdup(talloc_ctx, path);
  207|       |        goto exit;
  208|       |    }
  209|       |    // PathAllocCanonicalize() treats the "." of a \\.\ path as a directory and
  210|       |    // removes it, so skip it for device paths.
  211|       |    wchar_t *pathx = NULL;
  212|       |    if (wcsncmp(pathc, L"\\\\.\\", 4) &&
  213|       |        SUCCEEDED(PathAllocCanonicalize(pathc, PATHCCH_ALLOW_LONG_PATHS, &pathx)))
  214|       |        pathc = pathx;
  215|       |    result = mp_to_utf8(talloc_ctx, pathc);
  216|       |    LocalFree(pathx);
  217|       |#else
  218|      0|    if (!mp_path_is_absolute(bstr0(path))) {
  ------------------
  |  Branch (218:9): [True: 0, False: 0]
  ------------------
  219|      0|        char *cwd = mp_getcwd(tmp);
  220|      0|        if (!cwd) {
  ------------------
  |  Branch (220:13): [True: 0, False: 0]
  ------------------
  221|      0|            result = talloc_strdup(talloc_ctx, path);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  222|      0|            goto exit;
  223|      0|        }
  224|      0|        path = mp_path_join(tmp, cwd, path);
  225|      0|    }
  226|       |
  227|      0|    result = talloc_strdup(tmp, "");
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  228|      0|    const char *next;
  229|      0|    const char *end = path + strlen(path);
  230|       |
  231|      0|    for (const char *ptr = path; ptr < end; ptr = next + 1) {
  ------------------
  |  Branch (231:34): [True: 0, False: 0]
  ------------------
  232|      0|        next = memchr(ptr, '/', end - ptr);
  233|      0|        if (next == NULL)
  ------------------
  |  Branch (233:13): [True: 0, False: 0]
  ------------------
  234|      0|            next = end;
  235|       |
  236|      0|        switch (next - ptr) {
  ------------------
  |  Branch (236:17): [True: 0, False: 0]
  ------------------
  237|      0|            case 0:
  ------------------
  |  Branch (237:13): [True: 0, False: 0]
  ------------------
  238|      0|                continue;
  239|      0|            case 1:
  ------------------
  |  Branch (239:13): [True: 0, False: 0]
  ------------------
  240|      0|                if (ptr[0] == '.')
  ------------------
  |  Branch (240:21): [True: 0, False: 0]
  ------------------
  241|      0|                    continue;
  242|      0|                break;
  243|      0|            case 2:
  ------------------
  |  Branch (243:13): [True: 0, False: 0]
  ------------------
  244|       |                // Normalizing symlink/.. results in a wrong path: if the
  245|       |                // current working directory is /tmp/foo, and it is a symlink to
  246|       |                // /usr/bin, mpv ../file.mkv opens /usr/file.mkv, so we can't
  247|       |                // normalize the path to /tmp/file.mkv. Resolve symlinks to fix
  248|       |                // this. Otherwise we don't use realpath so users can use
  249|       |                // symlinks e.g. to hide how media files are distributed over
  250|       |                // real storage and move them while still resuming playback as
  251|       |                // long as the symlinked path doesn't change.
  252|      0|                if (ptr[0] == '.' && ptr[1] == '.') {
  ------------------
  |  Branch (252:21): [True: 0, False: 0]
  |  Branch (252:38): [True: 0, False: 0]
  ------------------
  253|      0|                    char *tmp_result = realpath(path, NULL);
  254|      0|                    result = talloc_strdup(talloc_ctx,
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  255|      0|                                           tmp_result ? tmp_result : path);
  ------------------
  |  Branch (255:44): [True: 0, False: 0]
  ------------------
  256|      0|                    free(tmp_result);
  257|      0|                    goto exit;
  258|      0|                }
  259|      0|        }
  260|       |
  261|      0|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|      0|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  262|      0|        result = talloc_strndup_append_buffer(result, ptr, next - ptr);
  ------------------
  |  |   60|      0|#define talloc_strndup_append_buffer    ta_talloc_strndup_append_buffer
  ------------------
  263|      0|    }
  264|       |
  265|      0|    if (!result[0])
  ------------------
  |  Branch (265:9): [True: 0, False: 0]
  ------------------
  266|      0|        result = talloc_strdup_append_buffer(result, "/");
  ------------------
  |  |   58|      0|#define talloc_strdup_append_buffer     ta_talloc_strdup_append_buffer
  ------------------
  267|       |
  268|      0|    result = talloc_steal(talloc_ctx, result);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  269|      0|#endif
  270|       |
  271|      0|exit:
  272|      0|    talloc_free(tmp);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  273|      0|    return result;
  274|      0|}
mp_is_url:
  290|  8.68M|{
  291|  8.68M|    int proto = bstr_find0(path, "://");
  292|  8.68M|    if (proto < 1)
  ------------------
  |  Branch (292:9): [True: 0, False: 8.68M]
  ------------------
  293|      0|        return false;
  294|       |    // Per RFC3986, the first character of the protocol must be alphabetic.
  295|       |    // The rest must be alphanumeric plus -, + and .
  296|  26.0M|    for (int i = 0; i < proto; i++) {
  ------------------
  |  Branch (296:21): [True: 17.3M, False: 8.68M]
  ------------------
  297|  17.3M|        unsigned char c = path.start[i];
  298|  17.3M|        if ((i == 0 && !mp_isalpha(c)) ||
  ------------------
  |  Branch (298:14): [True: 8.68M, False: 8.68M]
  |  Branch (298:24): [True: 0, False: 8.68M]
  ------------------
  299|  17.3M|            (!mp_isalnum(c) && c != '.' && c != '-' && c != '+'))
  ------------------
  |  Branch (299:14): [True: 0, False: 17.3M]
  |  Branch (299:32): [True: 0, False: 0]
  |  Branch (299:44): [True: 0, False: 0]
  |  Branch (299:56): [True: 0, False: 0]
  ------------------
  300|      0|        {
  301|      0|            return false;
  302|      0|        }
  303|  17.3M|    }
  304|  8.68M|    return true;
  305|  8.68M|}
mp_split_proto:
  310|  97.5k|{
  311|  97.5k|    if (!mp_is_url(path))
  ------------------
  |  Branch (311:9): [True: 0, False: 97.5k]
  ------------------
  312|      0|        return (bstr){0};
  313|  97.5k|    bstr r;
  314|  97.5k|    bstr_split_tok(path, "://", &r, out_url ? out_url : &(bstr){0});
  ------------------
  |  Branch (314:37): [True: 65.0k, False: 32.5k]
  ------------------
  315|  97.5k|    return r;
  316|  97.5k|}
path_utils.c:split_ext:
   97|   159k|{
   98|   159k|    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|   159k|    basename = bstr_splice(basename, bstrspn(basename, "."), basename.len);
  103|       |
  104|   159k|    int dot_pos = bstrrchr(basename, '.');
  105|   159k|    if (dot_pos < 0 || dot_pos == basename.len - 1)
  ------------------
  |  Branch (105:9): [True: 159k, False: 0]
  |  Branch (105:24): [True: 0, False: 0]
  ------------------
  106|   159k|        return (bstr){0};
  107|      0|    bstr ext = bstr_splice(basename, dot_pos + 1, basename.len);
  108|      0|    if (root)
  ------------------
  |  Branch (108:9): [True: 0, False: 0]
  ------------------
  109|      0|        *root = (bstr){path.start, ext.start - 1 - path.start};
  110|      0|    return ext;
  111|   159k|}

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

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

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

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

m_config_from_obj_desc_and_args:
  167|  32.5k|{
  168|  32.5k|    struct m_config *config = m_config_from_obj_desc(ta_parent, log, global, desc);
  169|  32.5k|    if (m_config_set_obj_params(config, log, global, desc, args) < 0)
  ------------------
  |  Branch (169:9): [True: 0, False: 32.5k]
  ------------------
  170|      0|        goto error;
  171|       |
  172|  32.5k|    return config;
  173|      0|error:
  174|      0|    talloc_free(config);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  175|       |    return NULL;
  176|  32.5k|}
m_config_restore_backups:
  235|  97.5k|{
  236|  97.5k|    restore_backups(&config->backup_opts, config);
  237|  97.5k|}
m_config_backup_watch_later_opts:
  276|  32.5k|{
  277|       |    // Runs once on the empty list, which is looked up by name.
  278|  32.5k|    mp_assert(!config->watch_later_backup_opts);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (278:5): [True: 32.5k, False: 0]
  ------------------
  279|  25.5M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (279:21): [True: 25.4M, False: 32.5k]
  ------------------
  280|  25.4M|        if (config->opts[n].data)
  ------------------
  |  Branch (280:13): [True: 23.8M, False: 1.62M]
  ------------------
  281|  23.8M|            add_backup(&config->watch_later_backup_opts, 0, &config->opts[n]);
  282|  25.4M|    }
  283|  32.5k|}
m_config_get_co_raw:
  300|  3.93M|{
  301|  3.93M|    struct m_config_option **co =
  302|  3.93M|        bsearch(&name, config->sorted_opts, config->num_opts,
  303|  3.93M|                sizeof(config->sorted_opts[0]), search_opt_name);
  304|  3.93M|    return co ? *co : NULL;
  ------------------
  |  Branch (304:12): [True: 3.57M, False: 357k]
  ------------------
  305|  3.93M|}
m_config_get_co:
  359|  2.79M|{
  360|  2.79M|    struct m_config_option *co = m_config_get_co_any(config, name);
  361|       |    // CLI aliases should not be real options, and are explicitly handled by
  362|       |    // m_config_set_option_cli(). So pretend it does not exist.
  363|  2.79M|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (363:9): [True: 2.60M, False: 195k]
  |  Branch (363:15): [True: 227k, False: 2.37M]
  ------------------
  364|   227k|        co = NULL;
  365|  2.79M|    return co;
  366|  2.79M|}
m_config_get_co_count:
  369|  32.5k|{
  370|  32.5k|    return config->num_opts;
  371|  32.5k|}
m_config_get_co_index:
  374|  25.4M|{
  375|  25.4M|    return &config->opts[index];
  376|  25.4M|}
m_config_mark_co_flags:
  431|   682k|{
  432|   682k|    if (flags & M_SETOPT_FROM_CMDLINE)
  ------------------
  |  Branch (432:9): [True: 0, False: 682k]
  ------------------
  433|      0|        co->is_set_from_cmdline = true;
  434|       |
  435|   682k|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (435:9): [True: 292k, False: 390k]
  ------------------
  436|   292k|        co->is_set_from_config = true;
  437|   682k|}
m_config_set_update_dispatch_queue:
  530|  32.5k|{
  531|  32.5k|    m_config_cache_set_dispatch_change_cb(config->cache, dispatch,
  532|  32.5k|                                          async_change_cb, config);
  533|  32.5k|}
m_config_new:
  554|  65.0k|{
  555|  65.0k|    struct m_config *config = talloc(talloc_ctx, struct m_config);
  ------------------
  |  |   26|  65.0k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  65.0k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  65.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  65.0k|    talloc_set_destructor(config, config_destroy);
  ------------------
  |  |   41|  65.0k|#define talloc_set_destructor           ta_set_destructor
  ------------------
  557|  65.0k|    *config = (struct m_config){.log = log,};
  558|       |
  559|  65.0k|    config->shadow = m_config_shadow_new(root);
  560|       |
  561|  65.0k|    if (root->size) {
  ------------------
  |  Branch (561:9): [True: 65.0k, False: 0]
  ------------------
  562|  65.0k|        config->cache = m_config_cache_from_shadow(config, config->shadow, root);
  563|  65.0k|        config->optstruct = config->cache->opts;
  564|  65.0k|    }
  565|       |
  566|  65.0k|    int32_t optid = -1;
  567|  25.6M|    while (m_config_shadow_get_next_opt(config->shadow, &optid)) {
  ------------------
  |  Branch (567:12): [True: 25.5M, False: 65.0k]
  ------------------
  568|  25.5M|        char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  569|  25.5M|        const char *opt_name =
  570|  25.5M|            m_config_shadow_get_opt_name(config->shadow, optid, buf, sizeof(buf));
  571|       |
  572|  25.5M|        struct m_config_option co = {
  573|  25.5M|            .name = talloc_strdup(config, opt_name),
  ------------------
  |  |   50|  25.5M|#define talloc_strdup                   ta_xstrdup
  ------------------
  574|  25.5M|            .opt = m_config_shadow_get_opt(config->shadow, optid),
  575|  25.5M|            .opt_id = optid,
  576|  25.5M|        };
  577|       |
  578|  25.5M|        if (config->cache)
  ------------------
  |  Branch (578:13): [True: 25.5M, False: 0]
  ------------------
  579|  25.5M|            co.data = m_config_cache_get_opt_data(config->cache, optid);
  580|       |
  581|  25.5M|        MP_TARRAY_APPEND(config, config->opts, config->num_opts, co);
  ------------------
  |  |  105|  25.5M|    do {                                            \
  |  |  106|  25.5M|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  25.5M|    do {                                            \
  |  |  |  |   97|  25.5M|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  25.5M|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  25.5M|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  25.5M|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 325k, False: 25.2M]
  |  |  |  |  ------------------
  |  |  |  |   99|  25.5M|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   325k|    do {                                                        \
  |  |  |  |  |  |   89|   325k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   325k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   325k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   325k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   325k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   325k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   325k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 325k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  25.5M|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 25.5M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  25.5M|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  25.5M|        (idxvar)++;                                 \
  |  |  109|  25.5M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 25.5M]
  |  |  ------------------
  ------------------
  582|  25.5M|    }
  583|       |
  584|  65.0k|    config->sorted_opts = talloc_array(config, struct m_config_option *, config->num_opts);
  ------------------
  |  |   29|  65.0k|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|  65.0k|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  65.0k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|  25.6M|    for (int n = 0; n < config->num_opts; n++)
  ------------------
  |  Branch (585:21): [True: 25.5M, False: 65.0k]
  ------------------
  586|  25.5M|        config->sorted_opts[n] = &config->opts[n];
  587|  65.0k|    qsort(config->sorted_opts, config->num_opts, sizeof(config->sorted_opts[0]), compare_opt_name);
  588|       |
  589|  65.0k|    return config;
  590|  65.0k|}
m_config_notify_change_opt_ptr:
  623|  65.0k|{
  624|       |    notify_opt(config, ptr, true);
  625|  65.0k|}
m_config_set_option_raw:
  637|  2.60M|{
  638|  2.60M|    if (!co)
  ------------------
  |  Branch (638:9): [True: 0, False: 2.60M]
  ------------------
  639|      0|        return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  640|       |
  641|  2.60M|    int r = handle_set_opt_flags(config, co, flags);
  642|  2.60M|    if (r <= 1)
  ------------------
  |  Branch (642:9): [True: 1.91M, False: 682k]
  ------------------
  643|  1.91M|        return r;
  644|       |
  645|   682k|    r = m_config_handle_special_options(config, co, data, flags);
  646|   682k|    if (r != M_OPT_UNKNOWN)
  ------------------
  |  |  529|   682k|#define M_OPT_UNKNOWN           -1
  ------------------
  |  Branch (646:9): [True: 0, False: 682k]
  ------------------
  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|   682k|    if (!co->data)
  ------------------
  |  Branch (651:9): [True: 0, False: 682k]
  ------------------
  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|   682k|    if (config->profile_backup_tmp)
  ------------------
  |  Branch (654:9): [True: 0, False: 682k]
  ------------------
  655|      0|        ensure_backup(config->profile_backup_tmp, config->profile_backup_flags, co);
  656|       |
  657|   682k|    m_config_mark_co_flags(co, flags);
  658|       |
  659|   682k|    m_option_copy(co->opt, co->data, data);
  660|   682k|    if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (660:9): [True: 682k, False: 0]
  ------------------
  661|   682k|        force_self_notify_change_opt(config, co, false);
  662|       |
  663|   682k|    return 0;
  664|   682k|}
m_config_set_option_cli:
  739|  2.37M|{
  740|  2.37M|    int r;
  741|  2.37M|    mp_assert(config != NULL);
  ------------------
  |  |   41|  2.37M|#define mp_assert assert
  ------------------
  |  Branch (741:5): [True: 2.37M, False: 0]
  ------------------
  742|       |
  743|  2.37M|    bool negate;
  744|  2.37M|    struct m_config_option *co =
  745|  2.37M|        m_config_mogrify_cli_opt(config, &name, &negate, &(int){0});
  746|       |
  747|  2.37M|    if (!co) {
  ------------------
  |  Branch (747:9): [True: 162k, False: 2.21M]
  ------------------
  748|   162k|        r = M_OPT_UNKNOWN;
  ------------------
  |  |  529|   162k|#define M_OPT_UNKNOWN           -1
  ------------------
  749|   162k|        goto done;
  750|   162k|    }
  751|       |
  752|  2.21M|    if (negate) {
  ------------------
  |  Branch (752:9): [True: 0, False: 2.21M]
  ------------------
  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|  2.21M|    if (flags & M_SETOPT_FROM_CONFIG_FILE)
  ------------------
  |  Branch (761:9): [True: 2.21M, False: 0]
  ------------------
  762|  2.21M|        co->coalesce = true;
  763|       |
  764|       |    // This is the only mandatory function
  765|  2.21M|    mp_assert(co->opt->type->parse);
  ------------------
  |  |   41|  2.21M|#define mp_assert assert
  ------------------
  |  Branch (765:5): [True: 2.21M, False: 0]
  ------------------
  766|       |
  767|  2.21M|    r = handle_set_opt_flags(config, co, flags);
  768|  2.21M|    if (r <= 0)
  ------------------
  |  Branch (768:9): [True: 0, False: 2.21M]
  ------------------
  769|      0|        goto done;
  770|       |
  771|  2.21M|    if (r == 2) {
  ------------------
  |  Branch (771:9): [True: 292k, False: 1.91M]
  ------------------
  772|   292k|        MP_VERBOSE(config, "Setting option '%.*s' = '%.*s' (flags = %d)\n",
  ------------------
  |  |   92|   292k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.17M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 292k, False: 0]
  |  |  |  |  |  Branch (86:57): [True: 292k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  773|   292k|                   BSTR_P(name), BSTR_P(param), flags);
  774|   292k|    }
  775|       |
  776|  2.21M|    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|  2.21M|    if (co->data)
  ------------------
  |  Branch (780:9): [True: 2.11M, False: 97.5k]
  ------------------
  781|  2.11M|        m_option_copy(co->opt, &val, co->data);
  782|       |
  783|  2.21M|    r = m_option_parse(config->log, co->opt, name, param, &val);
  784|       |
  785|  2.21M|    if (r >= 0)
  ------------------
  |  Branch (785:9): [True: 2.21M, False: 0]
  ------------------
  786|  2.21M|        r = m_config_set_option_raw(config, co, &val, flags);
  787|       |
  788|  2.21M|    m_option_free(co->opt, &val);
  789|       |
  790|  2.37M|done:
  791|  2.37M|    if (r < 0 && r != M_OPT_EXIT) {
  ------------------
  |  |  545|   162k|#define M_OPT_EXIT              -6
  ------------------
  |  Branch (791:9): [True: 162k, False: 2.21M]
  |  Branch (791:18): [True: 162k, False: 0]
  ------------------
  792|   162k|        MP_ERR(config, "Error parsing option %.*s (%s)\n",
  ------------------
  |  |   89|   162k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   325k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 162k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  793|   162k|               BSTR_P(name), m_option_strerror(r));
  794|   162k|        r = M_OPT_INVALID;
  ------------------
  |  |  535|   162k|#define M_OPT_INVALID           -3
  ------------------
  795|   162k|    }
  796|  2.37M|    return r;
  797|  2.21M|}
m_config_set_option_node:
  801|   390k|{
  802|   390k|    int r;
  803|       |
  804|   390k|    struct m_config_option *co = m_config_get_co(config, name);
  805|   390k|    if (!co)
  ------------------
  |  Branch (805:9): [True: 0, False: 390k]
  ------------------
  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|   390k|    union m_option_value val = m_option_value_default;
  811|       |
  812|   390k|    r = m_option_set_node_or_string(mp_null_log, co->opt, name, &val, data);
  813|   390k|    if (r >= 0)
  ------------------
  |  Branch (813:9): [True: 390k, False: 0]
  ------------------
  814|   390k|        r = m_config_set_option_raw(config, co, &val, flags);
  815|       |
  816|   390k|    if (mp_msg_test(config->log, MSGL_V)) {
  ------------------
  |  Branch (816:9): [True: 0, False: 390k]
  ------------------
  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|   390k|    m_option_free(co->opt, &val);
  824|   390k|    return r;
  825|   390k|}
m_config_get_profile:
  939|   552k|{
  940|  4.58M|    for (struct m_profile *p = config->profiles; p; p = p->next) {
  ------------------
  |  Branch (940:50): [True: 4.12M, False: 455k]
  ------------------
  941|  4.12M|        if (bstr_equals0(name, p->name))
  ------------------
  |  Branch (941:13): [True: 97.5k, False: 4.03M]
  ------------------
  942|  97.5k|            return p;
  943|  4.12M|    }
  944|   455k|    return NULL;
  945|   552k|}
m_config_get_profile0:
  949|   552k|{
  950|   552k|    return m_config_get_profile(config, bstr0(name));
  951|   552k|}
m_config_add_profile:
  954|   455k|{
  955|   455k|    if (!name || !name[0])
  ------------------
  |  Branch (955:9): [True: 65.0k, False: 390k]
  |  Branch (955:18): [True: 0, False: 390k]
  ------------------
  956|  65.0k|        name = "default";
  957|   455k|    struct m_profile *p = m_config_get_profile0(config, name);
  958|   455k|    if (p)
  ------------------
  |  Branch (958:9): [True: 32.5k, False: 422k]
  ------------------
  959|  32.5k|        return p;
  960|   422k|    p = talloc_zero(config, struct m_profile);
  ------------------
  |  |   27|   422k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   422k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   422k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  961|   422k|    p->name = talloc_strdup(p, name);
  ------------------
  |  |   50|   422k|#define talloc_strdup                   ta_xstrdup
  ------------------
  962|   422k|    p->next = config->profiles;
  963|   422k|    config->profiles = p;
  964|   422k|    return p;
  965|   455k|}
m_config_set_profile_option:
  969|  2.08M|{
  970|  2.08M|    if (bstr_equals0(name, "profile-desc")) {
  ------------------
  |  Branch (970:9): [True: 0, False: 2.08M]
  ------------------
  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|  2.08M|    if (bstr_equals0(name, "profile-cond")) {
  ------------------
  |  Branch (975:9): [True: 0, False: 2.08M]
  ------------------
  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|  2.08M|    if (bstr_equals0(name, profile_restore_mode_opt.name)) {
  ------------------
  |  Branch (982:9): [True: 0, False: 2.08M]
  ------------------
  983|      0|        return m_option_parse(config->log, &profile_restore_mode_opt, name, val,
  984|      0|                              &p->restore_mode);
  985|      0|    }
  986|       |
  987|  2.08M|    int i = m_config_set_option_cli(config, name, val,
  988|  2.08M|                                    M_SETOPT_CHECK_ONLY |
  989|  2.08M|                                    M_SETOPT_FROM_CONFIG_FILE);
  990|  2.08M|    if (i < 0)
  ------------------
  |  Branch (990:9): [True: 162k, False: 1.91M]
  ------------------
  991|   162k|        return i;
  992|  1.91M|    p->opts = talloc_realloc(p, p->opts, char *, 2 * (p->num_opts + 2));
  ------------------
  |  |   33|  1.91M|#define talloc_realloc                  ta_xrealloc
  |  |  ------------------
  |  |  |  |  144|  1.91M|    (type *)ta_xrealloc_size(ta_parent, ptr, ta_calc_array_size(sizeof(type), count))
  |  |  |  |  ------------------
  |  |  |  |  |  |  158|  1.91M|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  1.91M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  1.91M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.91M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|  1.91M|    p->opts[p->num_opts * 2] = bstrto0(p, name);
  994|  1.91M|    p->opts[p->num_opts * 2 + 1] = bstrto0(p, val);
  995|  1.91M|    p->num_opts++;
  996|       |    p->opts[p->num_opts * 2] = p->opts[p->num_opts * 2 + 1] = NULL;
  997|  1.91M|    return 1;
  998|  2.08M|}
m_config_set_profile:
 1021|  65.0k|{
 1022|  65.0k|    MP_VERBOSE(config, "Applying profile '%s'...\n", name);
  ------------------
  |  |   92|  65.0k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  65.0k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1023|  65.0k|    struct m_profile *p = find_check_profile(config, name);
 1024|  65.0k|    if (!p)
  ------------------
  |  Branch (1024:9): [True: 0, False: 65.0k]
  ------------------
 1025|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
 1026|       |
 1027|  65.0k|    if (!config->profile_backup_tmp && p->restore_mode) {
  ------------------
  |  Branch (1027:9): [True: 65.0k, False: 0]
  |  Branch (1027:40): [True: 0, False: 65.0k]
  ------------------
 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|  65.0k|    char *profile_name = talloc_strdup(NULL, name);
  ------------------
  |  |   50|  65.0k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1033|       |    // Note that we don't check if profile applied correctly, it doesn't matter.
 1034|  65.0k|    MP_TARRAY_APPEND(config, config->profile_stack, config->profile_stack_depth, profile_name);
  ------------------
  |  |  105|  65.0k|    do {                                            \
  |  |  106|  65.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  65.0k|    do {                                            \
  |  |  |  |   97|  65.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  65.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  65.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  65.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 32.5k]
  |  |  |  |  ------------------
  |  |  |  |   99|  65.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  65.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 65.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  65.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  65.0k|        (idxvar)++;                                 \
  |  |  109|  65.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 65.0k]
  |  |  ------------------
  ------------------
 1035|  65.0k|    talloc_steal(config->profile_stack, profile_name);
  ------------------
  |  |   38|  65.0k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  65.0k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1036|   357k|    for (int i = 0; i < p->num_opts; i++) {
  ------------------
  |  Branch (1036:21): [True: 292k, False: 65.0k]
  ------------------
 1037|   292k|        m_config_set_option_cli(config,
 1038|   292k|                                bstr0(p->opts[2 * i]),
 1039|   292k|                                bstr0(p->opts[2 * i + 1]),
 1040|   292k|                                flags | M_SETOPT_FROM_CONFIG_FILE);
 1041|   292k|    }
 1042|  65.0k|    if (MP_TARRAY_POP(config->profile_stack, config->profile_stack_depth, &profile_name))
  ------------------
  |  |  153|  65.0k|    ((idxvar) > 0                                   \
  |  |  ------------------
  |  |  |  Branch (153:5): [True: 65.0k, False: 0]
  |  |  |  Branch (153:6): [True: 65.0k, False: 0]
  |  |  ------------------
  |  |  154|  65.0k|        ? (*(out) = (p)[--(idxvar)], true)          \
  |  |  155|  65.0k|        : false                                     \
  |  |  156|  65.0k|    )
  ------------------
 1043|  65.0k|        talloc_free(profile_name);
  ------------------
  |  |   47|  65.0k|#define talloc_free                     ta_free
  ------------------
 1044|       |
 1045|  65.0k|    if (config->profile_backup_tmp == &p->backups) {
  ------------------
  |  Branch (1045:9): [True: 0, False: 65.0k]
  ------------------
 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|  65.0k|    return 0;
 1056|  65.0k|}
m_config_finish_default_profile:
 1074|  32.5k|{
 1075|       |    struct m_profile *p = m_config_add_profile(config, NULL);
 1076|  32.5k|    m_config_set_profile(config, p->name, flags & ~M_SETOPT_FROM_CONFIG_FILE);
 1077|  32.5k|    p->num_opts = 0;
 1078|  32.5k|}
m_config_frontend.c:m_config_from_obj_desc:
  128|  32.5k|{
  129|  32.5k|    struct m_sub_options *root = talloc_ptrtype(NULL, root);
  ------------------
  |  |   34|  32.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  32.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|  32.5k|    *root = (struct m_sub_options){
  131|  32.5k|        .opts = desc->options,
  132|       |        // (global == NULL got repurposed to mean "no alloc")
  133|  32.5k|        .size = global ? desc->priv_size : 0,
  ------------------
  |  Branch (133:17): [True: 32.5k, False: 0]
  ------------------
  134|  32.5k|        .defaults = desc->priv_defaults,
  135|  32.5k|    };
  136|       |
  137|  32.5k|    struct m_config *c = m_config_new(talloc_ctx, log, root);
  138|  32.5k|    talloc_steal(c, root);
  ------------------
  |  |   38|  32.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  32.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  139|  32.5k|    c->global = global;
  140|  32.5k|    return c;
  141|  32.5k|}
m_config_frontend.c:m_config_set_obj_params:
  153|  32.5k|{
  154|  32.5k|    for (int n = 0; args && args[n * 2 + 0]; n++) {
  ------------------
  |  Branch (154:21): [True: 0, False: 32.5k]
  |  Branch (154:29): [True: 0, False: 0]
  ------------------
  155|      0|        bstr opt = bstr0(args[n * 2 + 0]);
  156|      0|        bstr val = bstr0(args[n * 2 + 1]);
  157|      0|        if (m_config_set_option_cli(config, opt, val, 0) < 0)
  ------------------
  |  Branch (157:13): [True: 0, False: 0]
  ------------------
  158|      0|            return -1;
  159|      0|    }
  160|       |
  161|  32.5k|    return 0;
  162|  32.5k|}
m_config_frontend.c:restore_backups:
  220|  97.5k|{
  221|  97.5k|    while (*list) {
  ------------------
  |  Branch (221:12): [True: 0, False: 97.5k]
  ------------------
  222|      0|        struct m_opt_backup *bc = *list;
  223|      0|        *list = bc->next;
  224|       |
  225|      0|        if (!bc->nval || m_option_equal(bc->co->opt, bc->co->data, bc->nval))
  ------------------
  |  Branch (225:13): [True: 0, False: 0]
  |  Branch (225:26): [True: 0, False: 0]
  ------------------
  226|      0|            m_config_set_option_raw(config, bc->co, bc->backup, 0);
  227|       |
  228|      0|        if (bc->flags & BACKUP_LOCAL)
  ------------------
  |  |  186|      0|#define BACKUP_LOCAL 1
  ------------------
  |  Branch (228:13): [True: 0, False: 0]
  ------------------
  229|      0|            bc->co->is_set_locally = false;
  230|      0|        talloc_free(bc);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  231|      0|    }
  232|  97.5k|}
m_config_frontend.c:add_backup:
  190|  23.8M|{
  191|  23.8M|    struct m_opt_backup *bc = talloc_ptrtype(NULL, bc);
  ------------------
  |  |   34|  23.8M|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  23.8M|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  23.8M|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|  23.8M|    talloc_set_destructor(bc, backup_dtor);
  ------------------
  |  |   41|  23.8M|#define talloc_set_destructor           ta_set_destructor
  ------------------
  193|  23.8M|    *bc = (struct m_opt_backup) {
  194|  23.8M|        .co = co,
  195|  23.8M|        .backup = talloc_zero_size(bc, co->opt->type->size),
  ------------------
  |  |   44|  23.8M|#define talloc_zero_size                ta_xzalloc_size
  |  |  ------------------
  |  |  |  |  121|  23.8M|#define ta_xzalloc_size(...)            ta_oom_p(ta_zalloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  23.8M|#define ta_zalloc_size(...)     ta_dbg_set_loc(ta_zalloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  23.8M|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  23.8M|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  23.8M|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  23.8M|        .nval = flags & BACKUP_NVAL
  ------------------
  |  |  187|  23.8M|#define BACKUP_NVAL 2
  ------------------
  |  Branch (196:17): [True: 0, False: 23.8M]
  ------------------
  197|  23.8M|            ? 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|  23.8M|        .flags = flags,
  199|  23.8M|    };
  200|  23.8M|    m_option_copy(co->opt, bc->backup, co->data);
  201|  23.8M|    bc->next = *list;
  202|  23.8M|    *list = bc;
  203|  23.8M|    if (bc->flags & BACKUP_LOCAL)
  ------------------
  |  |  186|  23.8M|#define BACKUP_LOCAL 1
  ------------------
  |  Branch (203:9): [True: 0, False: 23.8M]
  ------------------
  204|      0|        co->is_set_locally = true;
  205|  23.8M|}
m_config_frontend.c:backup_dtor:
  179|  23.8M|{
  180|  23.8M|    struct m_opt_backup *bc = p;
  181|  23.8M|    m_option_free(bc->co->opt, bc->backup);
  182|  23.8M|    if (bc->nval)
  ------------------
  |  Branch (182:9): [True: 0, False: 23.8M]
  ------------------
  183|      0|        m_option_free(bc->co->opt, bc->nval);
  184|  23.8M|}
m_config_frontend.c:search_opt_name:
  293|  35.2M|{
  294|  35.2M|    const struct m_config_option *co = *(const struct m_config_option **)pelem;
  295|  35.2M|    return bstrcmp0(*(const bstr *)pkey, co->name);
  296|  35.2M|}
m_config_frontend.c:m_config_get_co_any:
  310|  3.18M|{
  311|  3.18M|    struct m_config_option *co = m_config_get_co_raw(config, name);
  312|  3.18M|    if (!co)
  ------------------
  |  Branch (312:9): [True: 357k, False: 2.82M]
  ------------------
  313|   357k|        return NULL;
  314|       |
  315|  2.82M|    const char *prefix = config->is_toplevel ? "--" : "";
  ------------------
  |  Branch (315:26): [True: 2.82M, False: 0]
  ------------------
  316|  2.82M|    if (co->opt->type == &m_option_type_alias) {
  ------------------
  |  Branch (316:9): [True: 0, False: 2.82M]
  ------------------
  317|      0|        char buf[M_CONFIG_MAX_OPT_NAME_LEN];
  318|      0|        const char *alias = m_config_shadow_get_alias_from_opt(config->shadow, co->opt_id,
  319|      0|                                                               buf, sizeof(buf));
  320|      0|        if (co->opt->deprecation_message && !co->warning_was_printed) {
  ------------------
  |  Branch (320:13): [True: 0, False: 0]
  |  Branch (320:45): [True: 0, False: 0]
  ------------------
  321|      0|            if (co->opt->deprecation_message[0]) {
  ------------------
  |  Branch (321:17): [True: 0, False: 0]
  ------------------
  322|      0|                MP_WARN(config, "Warning: option %s%s was replaced with "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  323|      0|                        "%s%s: %s\n", prefix, co->name, prefix, alias,
  324|      0|                        co->opt->deprecation_message);
  325|      0|            } else {
  326|      0|                MP_WARN(config, "Warning: option %s%s was replaced with "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  327|      0|                        "%s%s and might be removed in the future.\n",
  328|      0|                        prefix, co->name, prefix, alias);
  329|      0|            }
  330|      0|            co->warning_was_printed = true;
  331|      0|        }
  332|      0|        return m_config_get_co_any(config, bstr0(alias));
  333|  2.82M|    } else if (co->opt->type == &m_option_type_removed) {
  ------------------
  |  Branch (333:16): [True: 0, False: 2.82M]
  ------------------
  334|      0|        if (!co->warning_was_printed) {
  ------------------
  |  Branch (334:13): [True: 0, False: 0]
  ------------------
  335|      0|            char *msg = co->opt->priv;
  336|      0|            if (msg) {
  ------------------
  |  Branch (336:17): [True: 0, False: 0]
  ------------------
  337|      0|                MP_FATAL(config, "Option %s%s was removed: %s\n",
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  338|      0|                         prefix, co->name, msg);
  339|      0|            } else {
  340|      0|                MP_FATAL(config, "Option %s%s was removed.\n",
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  341|      0|                         prefix, co->name);
  342|      0|            }
  343|      0|            co->warning_was_printed = true;
  344|      0|        }
  345|      0|        return NULL;
  346|  2.82M|    } else if (co->opt->deprecation_message) {
  ------------------
  |  Branch (346:16): [True: 0, False: 2.82M]
  ------------------
  347|      0|        if (!co->warning_was_printed) {
  ------------------
  |  Branch (347:13): [True: 0, False: 0]
  ------------------
  348|      0|            MP_WARN(config, "Warning: option %s%s is deprecated "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  349|      0|                    "and might be removed in the future (%s).\n",
  350|      0|                    prefix, co->name, co->opt->deprecation_message);
  351|      0|            co->warning_was_printed = true;
  352|      0|        }
  353|      0|    }
  354|  2.82M|    return co;
  355|  2.82M|}
m_config_frontend.c:config_destroy:
  536|  65.0k|{
  537|  65.0k|    struct m_config *config = p;
  538|  65.0k|    config->option_change_callback = NULL;
  539|  65.0k|    m_config_restore_backups(config);
  540|       |
  541|  65.0k|    struct m_opt_backup **list = &config->watch_later_backup_opts;
  542|  23.9M|    while (*list) {
  ------------------
  |  Branch (542:12): [True: 23.8M, False: 65.0k]
  ------------------
  543|  23.8M|        struct m_opt_backup *bc = *list;
  544|  23.8M|        *list = bc->next;
  545|  23.8M|        talloc_free(bc);
  ------------------
  |  |   47|  23.8M|#define talloc_free                     ta_free
  ------------------
  546|  23.8M|    }
  547|       |
  548|  65.0k|    talloc_free(config->cache);
  ------------------
  |  |   47|  65.0k|#define talloc_free                     ta_free
  ------------------
  549|  65.0k|    talloc_free(config->shadow);
  ------------------
  |  |   47|  65.0k|#define talloc_free                     ta_free
  ------------------
  550|  65.0k|}
m_config_frontend.c:compare_opt_name:
  286|   200M|{
  287|   200M|    const struct m_config_option *a = *(const struct m_config_option **)pa;
  288|   200M|    const struct m_config_option *b = *(const struct m_config_option **)pb;
  289|   200M|    return strcmp(a->name, b->name);
  290|   200M|}
m_config_frontend.c:notify_opt:
  608|  65.0k|{
  609|  3.05M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (609:21): [True: 3.05M, False: 0]
  ------------------
  610|  3.05M|        struct m_config_option *co = &config->opts[n];
  611|  3.05M|        if (co->data == ptr) {
  ------------------
  |  Branch (611:13): [True: 65.0k, False: 2.99M]
  ------------------
  612|  65.0k|            if (m_config_cache_write_opt(config->cache, co->data))
  ------------------
  |  Branch (612:17): [True: 0, False: 65.0k]
  ------------------
  613|      0|                force_self_notify_change_opt(config, co, self_notification);
  614|  65.0k|            return;
  615|  65.0k|        }
  616|  3.05M|    }
  617|       |    // ptr doesn't point to any config->optstruct field declared in the
  618|       |    // option list?
  619|      0|    mp_assert(false);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (619:5): [Folded, False: 0]
  ------------------
  620|      0|}
m_config_frontend.c:handle_set_opt_flags:
  401|  4.81M|{
  402|  4.81M|    uint64_t optflags = co->opt->flags;
  403|  4.81M|    bool set = !(flags & M_SETOPT_CHECK_ONLY);
  404|       |
  405|  4.81M|    if ((flags & M_SETOPT_PRE_PARSE_ONLY) && !(optflags & M_OPT_PRE_PARSE))
  ------------------
  |  |  471|      0|#define M_OPT_PRE_PARSE         (UINT64_C(1) << 62)
  ------------------
  |  Branch (405:9): [True: 0, False: 4.81M]
  |  Branch (405:46): [True: 0, False: 0]
  ------------------
  406|      0|        return 0;
  407|       |
  408|  4.81M|    if ((flags & M_SETOPT_PRESERVE_CMDLINE) && co->is_set_from_cmdline)
  ------------------
  |  Branch (408:9): [True: 0, False: 4.81M]
  |  Branch (408:48): [True: 0, False: 0]
  ------------------
  409|      0|        set = false;
  410|       |
  411|  4.81M|    if ((flags & M_SETOPT_NO_OVERWRITE) &&
  ------------------
  |  Branch (411:9): [True: 0, False: 4.81M]
  ------------------
  412|      0|        (co->is_set_from_cmdline || co->is_set_from_config))
  ------------------
  |  Branch (412:10): [True: 0, False: 0]
  |  Branch (412:37): [True: 0, False: 0]
  ------------------
  413|      0|        set = false;
  414|       |
  415|  4.81M|    if ((flags & M_SETOPT_NO_PRE_PARSE) && (optflags & M_OPT_PRE_PARSE))
  ------------------
  |  |  471|      0|#define M_OPT_PRE_PARSE         (UINT64_C(1) << 62)
  ------------------
  |  Branch (415:9): [True: 0, False: 4.81M]
  |  Branch (415:44): [True: 0, False: 0]
  ------------------
  416|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  417|       |
  418|       |    // Check if this option isn't forbidden in the current mode
  419|  4.81M|    if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (optflags & M_OPT_NOCFG)) {
  ------------------
  |  |  468|  4.42M|#define M_OPT_NOCFG             (UINT64_C(1) << 63)
  ------------------
  |  Branch (419:9): [True: 4.42M, False: 390k]
  |  Branch (419:48): [True: 0, False: 4.42M]
  ------------------
  420|      0|        MP_ERR(config, "The %s option can't be used in a config file.\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  421|      0|               co->name);
  422|      0|        return M_OPT_INVALID;
  ------------------
  |  |  535|      0|#define M_OPT_INVALID           -3
  ------------------
  423|      0|    }
  424|  4.81M|    if ((flags & M_SETOPT_BACKUP) && set)
  ------------------
  |  Branch (424:9): [True: 0, False: 4.81M]
  |  Branch (424:38): [True: 0, False: 0]
  ------------------
  425|      0|        ensure_backup(&config->backup_opts, BACKUP_LOCAL, co);
  ------------------
  |  |  186|      0|#define BACKUP_LOCAL 1
  ------------------
  426|       |
  427|  4.81M|    return set ? 2 : 1;
  ------------------
  |  Branch (427:12): [True: 975k, False: 3.83M]
  ------------------
  428|  4.81M|}
m_config_frontend.c:m_config_handle_special_options:
  446|   682k|{
  447|   682k|    if (config->use_profiles && strcmp(co->name, "profile") == 0) {
  ------------------
  |  Branch (447:9): [True: 682k, False: 0]
  |  Branch (447:33): [True: 0, False: 682k]
  ------------------
  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|   682k|    if (config->includefunc && strcmp(co->name, "include") == 0) {
  ------------------
  |  Branch (467:9): [True: 682k, False: 0]
  |  Branch (467:32): [True: 0, False: 682k]
  ------------------
  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|   682k|    if (config->use_profiles && strcmp(co->name, "show-profile") == 0)
  ------------------
  |  Branch (483:9): [True: 682k, False: 0]
  |  Branch (483:33): [True: 0, False: 682k]
  ------------------
  484|      0|        return show_profile(config, bstr0(*(char **)data), 0);
  485|       |
  486|   682k|    if (config->is_toplevel && (strcmp(co->name, "h") == 0 ||
  ------------------
  |  Branch (486:9): [True: 682k, False: 0]
  |  Branch (486:33): [True: 0, False: 682k]
  ------------------
  487|   682k|                                strcmp(co->name, "help") == 0))
  ------------------
  |  Branch (487:33): [True: 0, False: 682k]
  ------------------
  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|   682k|    if (strcmp(co->name, "list-options") == 0) {
  ------------------
  |  Branch (496:9): [True: 0, False: 682k]
  ------------------
  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|   682k|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|   682k|#define M_OPT_UNKNOWN           -1
  ------------------
  502|   682k|}
m_config_frontend.c:force_self_notify_change_opt:
  597|   682k|{
  598|   682k|    int changed =
  599|   682k|        m_config_cache_get_option_change_mask(config->cache, co->opt_id);
  600|       |
  601|   682k|    if (config->option_change_callback) {
  ------------------
  |  Branch (601:9): [True: 0, False: 682k]
  ------------------
  602|      0|        config->option_change_callback(config->option_change_callback_ctx, co,
  603|      0|                                       changed, self_notification);
  604|      0|    }
  605|   682k|}
m_config_frontend.c:m_config_mogrify_cli_opt:
  673|  2.37M|{
  674|  2.37M|    *out_negate = false;
  675|  2.37M|    *out_add_flags = 0;
  676|       |
  677|  2.37M|    struct m_config_option *co = m_config_get_co(config, *name);
  678|  2.37M|    if (co)
  ------------------
  |  Branch (678:9): [True: 1.98M, False: 390k]
  ------------------
  679|  1.98M|        return co;
  680|       |
  681|       |    // Turn "--no-foo" into "foo" + set *out_negate.
  682|   390k|    bstr no_name = *name;
  683|   390k|    if (!co && bstr_eatstart0(&no_name, "no-")) {
  ------------------
  |  Branch (683:9): [True: 390k, False: 0]
  |  Branch (683:16): [True: 0, False: 390k]
  ------------------
  684|      0|        co = m_config_get_co(config, no_name);
  685|      0|        if (!co)
  ------------------
  |  Branch (685:13): [True: 0, False: 0]
  ------------------
  686|      0|            return NULL;
  687|       |
  688|       |        // Not all choice types have this value - if they don't, then parsing
  689|       |        // them will simply result in an error. Good enough.
  690|      0|        if (!(co->opt->type->flags & M_OPT_TYPE_CHOICE) &&
  ------------------
  |  |  512|      0|#define M_OPT_TYPE_CHOICE               (1 << 1)
  ------------------
  |  Branch (690:13): [True: 0, False: 0]
  ------------------
  691|      0|            !(co->opt->flags & M_OPT_ALLOW_NO))
  ------------------
  |  |  488|      0|#define M_OPT_ALLOW_NO          (UINT64_C(1) << 57)
  ------------------
  |  Branch (691:13): [True: 0, False: 0]
  ------------------
  692|      0|            return NULL;
  693|       |
  694|      0|        *name = no_name;
  695|      0|        *out_negate = true;
  696|      0|        return co;
  697|      0|    }
  698|       |
  699|       |    // Resolve CLI alias. (We don't allow you to combine them with "--no-".)
  700|   390k|    co = m_config_get_co_any(config, *name);
  701|   390k|    if (co && co->opt->type == &m_option_type_cli_alias)
  ------------------
  |  Branch (701:9): [True: 227k, False: 162k]
  |  Branch (701:15): [True: 227k, False: 0]
  ------------------
  702|   227k|        *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|   134M|    for (int n = 0; n < config->num_opts; n++) {
  ------------------
  |  Branch (706:21): [True: 134M, False: 162k]
  ------------------
  707|   134M|        co = &config->opts[n];
  708|   134M|        struct bstr basename = bstr0(co->name);
  709|       |
  710|   134M|        if (!bstr_startswith(*name, basename))
  ------------------
  |  Branch (710:13): [True: 133M, False: 552k]
  ------------------
  711|   133M|            continue;
  712|       |
  713|       |        // Aliased option + a suffix action, e.g. --opengl-shaders-append
  714|   552k|        if (co->opt->type == &m_option_type_alias)
  ------------------
  |  Branch (714:13): [True: 0, False: 552k]
  ------------------
  715|      0|            co = m_config_get_co_any(config, basename);
  716|   552k|        if (!co)
  ------------------
  |  Branch (716:13): [True: 0, False: 552k]
  ------------------
  717|      0|            continue;
  718|       |
  719|   552k|        const struct m_option_type *type = co->opt->type;
  720|   780k|        for (int i = 0; type->actions && type->actions[i].name; i++) {
  ------------------
  |  Branch (720:25): [True: 455k, False: 325k]
  |  Branch (720:42): [True: 455k, False: 0]
  ------------------
  721|   455k|            const struct m_option_action *action = &type->actions[i];
  722|   455k|            bstr suffix = bstr0(action->name);
  723|       |
  724|   455k|            if (bstr_endswith(*name, suffix) &&
  ------------------
  |  Branch (724:17): [True: 227k, False: 227k]
  ------------------
  725|   227k|                (name->len == basename.len + 1 + suffix.len) &&
  ------------------
  |  Branch (725:17): [True: 227k, False: 0]
  ------------------
  726|   227k|                name->start[basename.len] == '-')
  ------------------
  |  Branch (726:17): [True: 227k, False: 0]
  ------------------
  727|   227k|            {
  728|   227k|                *out_add_flags = action->flags;
  729|   227k|                return co;
  730|   227k|            }
  731|   455k|        }
  732|   552k|    }
  733|       |
  734|   162k|    return NULL;
  735|   390k|}
m_config_frontend.c:find_check_profile:
 1001|  65.0k|{
 1002|  65.0k|    struct m_profile *p = m_config_get_profile0(config, name);
 1003|  65.0k|    if (!p) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 65.0k]
  ------------------
 1004|      0|        MP_WARN(config, "Unknown profile '%s'.\n", name);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1005|      0|        return NULL;
 1006|      0|    }
 1007|  65.0k|    for (size_t i = 0; i < config->profile_stack_depth; ++i) {
  ------------------
  |  Branch (1007:24): [True: 0, False: 65.0k]
  ------------------
 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|  65.0k|    if (config->profile_stack_depth > MAX_PROFILE_DEPTH) {
  ------------------
  |  |   43|  65.0k|#define MAX_PROFILE_DEPTH 20
  ------------------
  |  Branch (1013:9): [True: 0, False: 65.0k]
  ------------------
 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|  65.0k|    return p;
 1018|  65.0k|}

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

client.c:m_option_free:
  589|  97.5k|{
  590|  97.5k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 97.5k, False: 0]
  ------------------
  591|  97.5k|        opt->type->free(dst);
  592|  97.5k|}
command.c:m_option_free:
  589|  32.5k|{
  590|  32.5k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 32.5k, False: 0]
  ------------------
  591|  32.5k|        opt->type->free(dst);
  592|  32.5k|}
f_output_chain.c:m_option_free:
  589|   227k|{
  590|   227k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 227k, False: 0]
  ------------------
  591|   227k|        opt->type->free(dst);
  592|   227k|}
f_output_chain.c:m_option_copy:
  582|  32.5k|{
  583|  32.5k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 32.5k, False: 0]
  ------------------
  584|  32.5k|        opt->type->copy(opt, dst, src);
  585|  32.5k|}
cmd.c:m_option_free:
  589|   195k|{
  590|   195k|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 65.0k, False: 130k]
  ------------------
  591|  65.0k|        opt->type->free(dst);
  592|   195k|}
cmd.c:m_option_copy:
  582|  32.5k|{
  583|  32.5k|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 32.5k, False: 0]
  ------------------
  584|  32.5k|        opt->type->copy(opt, dst, src);
  585|  32.5k|}
cmd.c:m_option_print:
  559|   195k|{
  560|   195k|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 195k, False: 0]
  ------------------
  561|   195k|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|   195k|}
m_config_core.c:m_option_free:
  589|   138M|{
  590|   138M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 23.9M, False: 115M]
  ------------------
  591|  23.9M|        opt->type->free(dst);
  592|   138M|}
m_config_core.c:m_option_equal:
  617|  1.33M|{
  618|       |    // Handle trivial equivalence.
  619|       |    // If not implemented, assume this type has no actual values => always equal.
  620|  1.33M|    if (a == b || !opt->type->equal)
  ------------------
  |  Branch (620:9): [True: 0, False: 1.33M]
  |  Branch (620:19): [True: 0, False: 1.33M]
  ------------------
  621|      0|        return true;
  622|  1.33M|    return opt->type->equal(opt, a, b);
  623|  1.33M|}
m_config_core.c:m_option_copy:
  582|  24.7M|{
  583|  24.7M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 24.7M, False: 0]
  ------------------
  584|  24.7M|        opt->type->copy(opt, dst, src);
  585|  24.7M|}
m_config_frontend.c:m_option_copy:
  582|  26.6M|{
  583|  26.6M|    if (opt->type->copy)
  ------------------
  |  Branch (583:9): [True: 26.6M, False: 0]
  ------------------
  584|  26.6M|        opt->type->copy(opt, dst, src);
  585|  26.6M|}
m_config_frontend.c:m_option_free:
  589|  26.4M|{
  590|  26.4M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 4.84M, False: 21.6M]
  ------------------
  591|  4.84M|        opt->type->free(dst);
  592|  26.4M|}
m_option.c:m_option_set_node:
  597|  32.5k|{
  598|  32.5k|    if (opt->type->set)
  ------------------
  |  Branch (598:9): [True: 32.5k, False: 0]
  ------------------
  599|  32.5k|        return opt->type->set(opt, dst, src);
  600|      0|    return M_OPT_UNKNOWN;
  ------------------
  |  |  529|      0|#define M_OPT_UNKNOWN           -1
  ------------------
  601|  32.5k|}
m_property.c:m_option_pretty_print:
  569|   845k|{
  570|   845k|    m_option_t o = *opt;
  571|   845k|    if (fixed_len)
  ------------------
  |  Branch (571:9): [True: 0, False: 845k]
  ------------------
  572|      0|        o.flags |= M_OPT_FIXED_LEN_PRINT;
  ------------------
  |  |  494|      0|#define M_OPT_FIXED_LEN_PRINT   (UINT64_C(1) << 55)
  ------------------
  573|   845k|    if (opt->type->pretty_print)
  ------------------
  |  Branch (573:9): [True: 0, False: 845k]
  ------------------
  574|      0|        return opt->type->pretty_print(&o, val_ptr);
  575|   845k|    else
  576|   845k|        return m_option_print(&o, val_ptr);
  577|   845k|}
m_property.c:m_option_free:
  589|  2.53M|{
  590|  2.53M|    if (opt->type->free)
  ------------------
  |  Branch (590:9): [True: 2.53M, False: 0]
  ------------------
  591|  2.53M|        opt->type->free(dst);
  592|  2.53M|}
m_property.c:m_option_print:
  559|  2.53M|{
  560|  2.53M|    if (opt->type->print)
  ------------------
  |  Branch (560:9): [True: 2.53M, False: 0]
  ------------------
  561|  2.53M|        return opt->type->print(opt, val_ptr);
  562|      0|    else
  563|      0|        return NULL;
  564|  2.53M|}

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

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

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

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

client.c:mp_mutex_init:
  113|   162k|{
  114|   162k|#ifndef NDEBUG
  115|   162k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   162k|    int ret = 0;
  121|   162k|    pthread_mutexattr_t attr;
  122|   162k|    ret = pthread_mutexattr_init(&attr);
  123|   162k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 162k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   162k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   162k|    ret = pthread_mutex_init(mutex, &attr);
  128|   162k|    pthread_mutexattr_destroy(&attr);
  129|   162k|    mp_assert(!ret);
  ------------------
  |  |   41|   162k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 162k, False: 0]
  ------------------
  130|   162k|    return ret;
  131|   162k|}
client.c:mp_cond_init:
  139|  65.0k|{
  140|  65.0k|    mp_assert(cond);
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 65.0k, False: 0]
  ------------------
  141|       |
  142|  65.0k|    int ret = 0;
  143|  65.0k|    pthread_condattr_t attr;
  144|  65.0k|    ret = pthread_condattr_init(&attr);
  145|  65.0k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 65.0k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  65.0k|    cond->clk_id = CLOCK_REALTIME;
  149|  65.0k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  65.0k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 65.0k, False: 0]
  ------------------
  151|  65.0k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  65.0k|#endif
  153|       |
  154|  65.0k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  65.0k|    pthread_condattr_destroy(&attr);
  156|  65.0k|    return ret;
  157|  65.0k|}
client.c:mp_cond_timedwait_until:
  205|   340k|{
  206|   340k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   340k|}
client.c:mp_cond_timedwait:
  184|   340k|{
  185|   340k|    mp_assert(cond);
  ------------------
  |  |   41|   340k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 340k, False: 0]
  ------------------
  186|       |
  187|   340k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   340k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 340k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   340k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   340k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 263k, False: 77.3k]
  ------------------
  190|   263k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  77.3k|    struct timespec ts;
  193|  77.3k|    clock_gettime(cond->clk_id, &ts);
  194|  77.3k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  77.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  77.3k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  77.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  77.3k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  77.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 77.3k, False: 1]
  ------------------
  197|  77.3k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  77.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  77.3k|        ts.tv_sec++;
  199|  77.3k|    }
  200|       |
  201|  77.3k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   340k|}
client.c:mp_cond_destroy:
  160|  65.0k|{
  161|  65.0k|    mp_assert(cond);
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 65.0k, False: 0]
  ------------------
  162|  65.0k|    return pthread_cond_destroy(&cond->cond);
  163|  65.0k|}
client.c:mp_thread_set_name:
  222|  32.5k|{
  223|  32.5k|#if HAVE_GLIBC_THREAD_NAME
  224|  32.5k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|}
client.c:mp_cond_broadcast:
  166|   341k|{
  167|   341k|    mp_assert(cond);
  ------------------
  |  |   41|   341k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 341k, False: 0]
  ------------------
  168|   341k|    return pthread_cond_broadcast(&cond->cond);
  169|   341k|}
loadfile.c:mp_thread_set_name:
  222|  32.5k|{
  223|  32.5k|#if HAVE_GLIBC_THREAD_NAME
  224|  32.5k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|}
main.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
osd.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
clipboard.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
dec_sub.c:mp_mutex_init:
  113|  6.68k|{
  114|  6.68k|#ifndef NDEBUG
  115|  6.68k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  6.68k|    int ret = 0;
  121|  6.68k|    pthread_mutexattr_t attr;
  122|  6.68k|    ret = pthread_mutexattr_init(&attr);
  123|  6.68k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 6.68k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  6.68k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  6.68k|    ret = pthread_mutex_init(mutex, &attr);
  128|  6.68k|    pthread_mutexattr_destroy(&attr);
  129|  6.68k|    mp_assert(!ret);
  ------------------
  |  |   41|  6.68k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 6.68k, False: 0]
  ------------------
  130|  6.68k|    return ret;
  131|  6.68k|}
vo.c:mp_mutex_init:
  113|  65.0k|{
  114|  65.0k|#ifndef NDEBUG
  115|  65.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  65.0k|    int ret = 0;
  121|  65.0k|    pthread_mutexattr_t attr;
  122|  65.0k|    ret = pthread_mutexattr_init(&attr);
  123|  65.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 65.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  65.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  65.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  65.0k|    pthread_mutexattr_destroy(&attr);
  129|  65.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 65.0k, False: 0]
  ------------------
  130|  65.0k|    return ret;
  131|  65.0k|}
vo.c:mp_cond_init:
  139|  32.5k|{
  140|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 32.5k, False: 0]
  ------------------
  141|       |
  142|  32.5k|    int ret = 0;
  143|  32.5k|    pthread_condattr_t attr;
  144|  32.5k|    ret = pthread_condattr_init(&attr);
  145|  32.5k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 32.5k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  32.5k|    cond->clk_id = CLOCK_REALTIME;
  149|  32.5k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  32.5k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 32.5k, False: 0]
  ------------------
  151|  32.5k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  32.5k|#endif
  153|       |
  154|  32.5k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  32.5k|    pthread_condattr_destroy(&attr);
  156|  32.5k|    return ret;
  157|  32.5k|}
vo.c:mp_thread_set_name:
  222|  32.5k|{
  223|  32.5k|#if HAVE_GLIBC_THREAD_NAME
  224|  32.5k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|}
vo.c:mp_thread_set_min_timer_slack:
  237|  32.5k|{
  238|  32.5k|#if HAVE_PR_SET_TIMERSLACK
  239|       |    prctl(PR_SET_TIMERSLACK, 1UL);
  240|  32.5k|#endif
  241|  32.5k|}
vo.c:mp_cond_broadcast:
  166|  2.14M|{
  167|  2.14M|    mp_assert(cond);
  ------------------
  |  |   41|  2.14M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 2.14M, False: 0]
  ------------------
  168|  2.14M|    return pthread_cond_broadcast(&cond->cond);
  169|  2.14M|}
vo.c:mp_cond_destroy:
  160|  32.5k|{
  161|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 32.5k, False: 0]
  ------------------
  162|  32.5k|    return pthread_cond_destroy(&cond->cond);
  163|  32.5k|}
vo.c:mp_cond_timedwait_until:
  205|  1.17M|{
  206|  1.17M|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|  1.17M|}
vo.c:mp_cond_timedwait:
  184|  1.17M|{
  185|  1.17M|    mp_assert(cond);
  ------------------
  |  |   41|  1.17M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 1.17M, False: 0]
  ------------------
  186|       |
  187|  1.17M|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  1.17M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 1.17M]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  1.17M|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  1.17M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 0, False: 1.17M]
  ------------------
  190|      0|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  1.17M|    struct timespec ts;
  193|  1.17M|    clock_gettime(cond->clk_id, &ts);
  194|  1.17M|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  1.17M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  1.17M|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  1.17M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  1.17M|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  1.17M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 1.17M, False: 1]
  ------------------
  197|  1.17M|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  1.17M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  1.17M|        ts.tv_sec++;
  199|  1.17M|    }
  200|       |
  201|  1.17M|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  1.17M|}
vo.c:mp_cond_wait:
  178|  32.4k|{
  179|  32.4k|    mp_assert(cond);
  ------------------
  |  |   41|  32.4k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 32.4k, False: 0]
  ------------------
  180|  32.4k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  32.4k|}
msg.c:mp_mutex_init:
  113|   130k|{
  114|   130k|#ifndef NDEBUG
  115|   130k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   130k|    int ret = 0;
  121|   130k|    pthread_mutexattr_t attr;
  122|   130k|    ret = pthread_mutexattr_init(&attr);
  123|   130k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 130k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   130k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   130k|    ret = pthread_mutex_init(mutex, &attr);
  128|   130k|    pthread_mutexattr_destroy(&attr);
  129|   130k|    mp_assert(!ret);
  ------------------
  |  |   41|   130k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 130k, False: 0]
  ------------------
  130|   130k|    return ret;
  131|   130k|}
msg.c:mp_cond_init:
  139|  32.5k|{
  140|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 32.5k, False: 0]
  ------------------
  141|       |
  142|  32.5k|    int ret = 0;
  143|  32.5k|    pthread_condattr_t attr;
  144|  32.5k|    ret = pthread_condattr_init(&attr);
  145|  32.5k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 32.5k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  32.5k|    cond->clk_id = CLOCK_REALTIME;
  149|  32.5k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  32.5k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 32.5k, False: 0]
  ------------------
  151|  32.5k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  32.5k|#endif
  153|       |
  154|  32.5k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  32.5k|    pthread_condattr_destroy(&attr);
  156|  32.5k|    return ret;
  157|  32.5k|}
msg.c:mp_cond_destroy:
  160|  32.5k|{
  161|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 32.5k, False: 0]
  ------------------
  162|  32.5k|    return pthread_cond_destroy(&cond->cond);
  163|  32.5k|}
stats.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
demux.c:mp_cond_destroy:
  160|   412k|{
  161|   412k|    mp_assert(cond);
  ------------------
  |  |   41|   412k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 412k, False: 0]
  ------------------
  162|   412k|    return pthread_cond_destroy(&cond->cond);
  163|   412k|}
demux.c:mp_cond_signal:
  172|   539k|{
  173|   539k|    mp_assert(cond);
  ------------------
  |  |   41|   539k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 539k, False: 0]
  ------------------
  174|   539k|    return pthread_cond_signal(&cond->cond);
  175|   539k|}
demux.c:mp_thread_set_name:
  222|  55.1k|{
  223|  55.1k|#if HAVE_GLIBC_THREAD_NAME
  224|  55.1k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 55.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|  55.1k|}
demux.c:mp_cond_timedwait_until:
  205|   133k|{
  206|   133k|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|   133k|}
demux.c:mp_cond_timedwait:
  184|   133k|{
  185|   133k|    mp_assert(cond);
  ------------------
  |  |   41|   133k|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 133k, False: 0]
  ------------------
  186|       |
  187|   133k|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|   133k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 133k]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|   133k|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|   133k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 109k, False: 24.7k]
  ------------------
  190|   109k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  24.7k|    struct timespec ts;
  193|  24.7k|    clock_gettime(cond->clk_id, &ts);
  194|  24.7k|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  24.7k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  24.7k|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  24.7k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  24.7k|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  24.7k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 24.5k, False: 241]
  ------------------
  197|  24.5k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  24.5k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  24.5k|        ts.tv_sec++;
  199|  24.5k|    }
  200|       |
  201|  24.7k|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|   133k|}
demux.c:mp_mutex_init:
  113|   412k|{
  114|   412k|#ifndef NDEBUG
  115|   412k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   412k|    int ret = 0;
  121|   412k|    pthread_mutexattr_t attr;
  122|   412k|    ret = pthread_mutexattr_init(&attr);
  123|   412k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 412k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   412k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   412k|    ret = pthread_mutex_init(mutex, &attr);
  128|   412k|    pthread_mutexattr_destroy(&attr);
  129|   412k|    mp_assert(!ret);
  ------------------
  |  |   41|   412k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 412k, False: 0]
  ------------------
  130|   412k|    return ret;
  131|   412k|}
demux.c:mp_cond_init:
  139|   412k|{
  140|   412k|    mp_assert(cond);
  ------------------
  |  |   41|   412k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 412k, False: 0]
  ------------------
  141|       |
  142|   412k|    int ret = 0;
  143|   412k|    pthread_condattr_t attr;
  144|   412k|    ret = pthread_condattr_init(&attr);
  145|   412k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 412k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|   412k|    cond->clk_id = CLOCK_REALTIME;
  149|   412k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|   412k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 412k, False: 0]
  ------------------
  151|   412k|        cond->clk_id = CLOCK_MONOTONIC;
  152|   412k|#endif
  153|       |
  154|   412k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|   412k|    pthread_condattr_destroy(&attr);
  156|   412k|    return ret;
  157|   412k|}
packet_pool.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
f_decoder_wrapper.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
filter.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
input.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
dispatch.c:mp_cond_destroy:
  160|  67.3k|{
  161|  67.3k|    mp_assert(cond);
  ------------------
  |  |   41|  67.3k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 67.3k, False: 0]
  ------------------
  162|  67.3k|    return pthread_cond_destroy(&cond->cond);
  163|  67.3k|}
dispatch.c:mp_mutex_init:
  113|  67.3k|{
  114|  67.3k|#ifndef NDEBUG
  115|  67.3k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  67.3k|    int ret = 0;
  121|  67.3k|    pthread_mutexattr_t attr;
  122|  67.3k|    ret = pthread_mutexattr_init(&attr);
  123|  67.3k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 67.3k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  67.3k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  67.3k|    ret = pthread_mutex_init(mutex, &attr);
  128|  67.3k|    pthread_mutexattr_destroy(&attr);
  129|  67.3k|    mp_assert(!ret);
  ------------------
  |  |   41|  67.3k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 67.3k, False: 0]
  ------------------
  130|  67.3k|    return ret;
  131|  67.3k|}
dispatch.c:mp_cond_init:
  139|  67.3k|{
  140|  67.3k|    mp_assert(cond);
  ------------------
  |  |   41|  67.3k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 67.3k, False: 0]
  ------------------
  141|       |
  142|  67.3k|    int ret = 0;
  143|  67.3k|    pthread_condattr_t attr;
  144|  67.3k|    ret = pthread_condattr_init(&attr);
  145|  67.3k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 67.3k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  67.3k|    cond->clk_id = CLOCK_REALTIME;
  149|  67.3k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  67.3k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 67.3k, False: 0]
  ------------------
  151|  67.3k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  67.3k|#endif
  153|       |
  154|  67.3k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  67.3k|    pthread_condattr_destroy(&attr);
  156|  67.3k|    return ret;
  157|  67.3k|}
dispatch.c:mp_cond_wait:
  178|   506k|{
  179|   506k|    mp_assert(cond);
  ------------------
  |  |   41|   506k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 506k, False: 0]
  ------------------
  180|   506k|    return pthread_cond_wait(&cond->cond, mutex);
  181|   506k|}
dispatch.c:mp_cond_broadcast:
  166|  4.15M|{
  167|  4.15M|    mp_assert(cond);
  ------------------
  |  |   41|  4.15M|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 4.15M, False: 0]
  ------------------
  168|  4.15M|    return pthread_cond_broadcast(&cond->cond);
  169|  4.15M|}
dispatch.c:mp_cond_timedwait_until:
  205|  1.04M|{
  206|  1.04M|    return mp_cond_timedwait(cond, mutex, until - mp_time_ns());
  207|  1.04M|}
dispatch.c:mp_cond_timedwait:
  184|  1.04M|{
  185|  1.04M|    mp_assert(cond);
  ------------------
  |  |   41|  1.04M|#define mp_assert assert
  ------------------
  |  Branch (185:5): [True: 1.04M, False: 0]
  ------------------
  186|       |
  187|  1.04M|    timeout = MPMAX(0, timeout);
  ------------------
  |  |   44|  1.04M|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 1.04M]
  |  |  ------------------
  ------------------
  188|       |    // consider anything above 1000 days as infinity
  189|  1.04M|    if (timeout > MP_TIME_S_TO_NS(1000 * 24 * 60 * 60))
  ------------------
  |  |   71|  1.04M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (189:9): [True: 1.81k, False: 1.03M]
  ------------------
  190|  1.81k|        return pthread_cond_wait(&cond->cond, mutex);
  191|       |
  192|  1.03M|    struct timespec ts;
  193|  1.03M|    clock_gettime(cond->clk_id, &ts);
  194|  1.03M|    ts.tv_sec  += timeout / MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  1.03M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  195|  1.03M|    ts.tv_nsec += timeout % MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  1.03M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  196|  1.03M|    if (ts.tv_nsec >= MP_TIME_S_TO_NS(1)) {
  ------------------
  |  |   71|  1.03M|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  |  Branch (196:9): [True: 82.3k, False: 955k]
  ------------------
  197|  82.3k|        ts.tv_nsec -= MP_TIME_S_TO_NS(1);
  ------------------
  |  |   71|  82.3k|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  ------------------
  198|  82.3k|        ts.tv_sec++;
  199|  82.3k|    }
  200|       |
  201|  1.03M|    return pthread_cond_timedwait(&cond->cond, mutex, &ts);
  202|  1.04M|}
rendezvous.c:mp_cond_broadcast:
  166|  32.5k|{
  167|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 32.5k, False: 0]
  ------------------
  168|  32.5k|    return pthread_cond_broadcast(&cond->cond);
  169|  32.5k|}
rendezvous.c:mp_cond_wait:
  178|  32.5k|{
  179|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 32.5k, False: 0]
  ------------------
  180|  32.5k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  32.5k|}
thread_pool.c:mp_cond_broadcast:
  166|  32.5k|{
  167|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 32.5k, False: 0]
  ------------------
  168|  32.5k|    return pthread_cond_broadcast(&cond->cond);
  169|  32.5k|}
thread_pool.c:mp_cond_destroy:
  160|  32.5k|{
  161|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 32.5k, False: 0]
  ------------------
  162|  32.5k|    return pthread_cond_destroy(&cond->cond);
  163|  32.5k|}
thread_pool.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}
thread_pool.c:mp_cond_init:
  139|  32.5k|{
  140|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 32.5k, False: 0]
  ------------------
  141|       |
  142|  32.5k|    int ret = 0;
  143|  32.5k|    pthread_condattr_t attr;
  144|  32.5k|    ret = pthread_condattr_init(&attr);
  145|  32.5k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 32.5k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|  32.5k|    cond->clk_id = CLOCK_REALTIME;
  149|  32.5k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|  32.5k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 32.5k, False: 0]
  ------------------
  151|  32.5k|        cond->clk_id = CLOCK_MONOTONIC;
  152|  32.5k|#endif
  153|       |
  154|  32.5k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|  32.5k|    pthread_condattr_destroy(&attr);
  156|  32.5k|    return ret;
  157|  32.5k|}
thread_pool.c:mp_thread_set_name:
  222|  32.5k|{
  223|  32.5k|#if HAVE_GLIBC_THREAD_NAME
  224|  32.5k|    if (pthread_setname_np(pthread_self(), name) == ERANGE) {
  ------------------
  |  Branch (224:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|}
thread_pool.c:mp_cond_wait:
  178|  32.5k|{
  179|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (179:5): [True: 32.5k, False: 0]
  ------------------
  180|  32.5k|    return pthread_cond_wait(&cond->cond, mutex);
  181|  32.5k|}
thread_pool.c:mp_cond_signal:
  172|  32.5k|{
  173|  32.5k|    mp_assert(cond);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 32.5k, False: 0]
  ------------------
  174|  32.5k|    return pthread_cond_signal(&cond->cond);
  175|  32.5k|}
thread_tools.c:mp_cond_destroy:
  160|   292k|{
  161|   292k|    mp_assert(cond);
  ------------------
  |  |   41|   292k|#define mp_assert assert
  ------------------
  |  Branch (161:5): [True: 292k, False: 0]
  ------------------
  162|   292k|    return pthread_cond_destroy(&cond->cond);
  163|   292k|}
thread_tools.c:mp_cond_signal:
  172|   130k|{
  173|   130k|    mp_assert(cond);
  ------------------
  |  |   41|   130k|#define mp_assert assert
  ------------------
  |  Branch (173:5): [True: 130k, False: 0]
  ------------------
  174|   130k|    return pthread_cond_signal(&cond->cond);
  175|   130k|}
thread_tools.c:mp_mutex_init:
  113|   162k|{
  114|   162k|#ifndef NDEBUG
  115|   162k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|   162k|    int ret = 0;
  121|   162k|    pthread_mutexattr_t attr;
  122|   162k|    ret = pthread_mutexattr_init(&attr);
  123|   162k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 162k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|   162k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|   162k|    ret = pthread_mutex_init(mutex, &attr);
  128|   162k|    pthread_mutexattr_destroy(&attr);
  129|   162k|    mp_assert(!ret);
  ------------------
  |  |   41|   162k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 162k, False: 0]
  ------------------
  130|   162k|    return ret;
  131|   162k|}
thread_tools.c:mp_cond_init:
  139|   162k|{
  140|   162k|    mp_assert(cond);
  ------------------
  |  |   41|   162k|#define mp_assert assert
  ------------------
  |  Branch (140:5): [True: 162k, False: 0]
  ------------------
  141|       |
  142|   162k|    int ret = 0;
  143|   162k|    pthread_condattr_t attr;
  144|   162k|    ret = pthread_condattr_init(&attr);
  145|   162k|    if (ret)
  ------------------
  |  Branch (145:9): [True: 0, False: 162k]
  ------------------
  146|      0|        return ret;
  147|       |
  148|   162k|    cond->clk_id = CLOCK_REALTIME;
  149|   162k|#if HAVE_PTHREAD_CONDATTR_SETCLOCK
  150|   162k|    if (!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
  ------------------
  |  Branch (150:9): [True: 162k, False: 0]
  ------------------
  151|   162k|        cond->clk_id = CLOCK_MONOTONIC;
  152|   162k|#endif
  153|       |
  154|   162k|    ret = pthread_cond_init(&cond->cond, &attr);
  155|   162k|    pthread_condattr_destroy(&attr);
  156|   162k|    return ret;
  157|   162k|}
thread_tools.c:mp_cond_broadcast:
  166|   136k|{
  167|   136k|    mp_assert(cond);
  ------------------
  |  |   41|   136k|#define mp_assert assert
  ------------------
  |  Branch (167:5): [True: 136k, False: 0]
  ------------------
  168|   136k|    return pthread_cond_broadcast(&cond->cond);
  169|   136k|}
m_config_core.c:mp_mutex_init:
  113|  65.0k|{
  114|  65.0k|#ifndef NDEBUG
  115|  65.0k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  65.0k|    int ret = 0;
  121|  65.0k|    pthread_mutexattr_t attr;
  122|  65.0k|    ret = pthread_mutexattr_init(&attr);
  123|  65.0k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 65.0k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  65.0k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  65.0k|    ret = pthread_mutex_init(mutex, &attr);
  128|  65.0k|    pthread_mutexattr_destroy(&attr);
  129|  65.0k|    mp_assert(!ret);
  ------------------
  |  |   41|  65.0k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 65.0k, False: 0]
  ------------------
  130|  65.0k|    return ret;
  131|  65.0k|}
vd_lavc.c:mp_mutex_init:
  113|  32.5k|{
  114|  32.5k|#ifndef NDEBUG
  115|  32.5k|    int mutex_type = PTHREAD_MUTEX_ERRORCHECK;
  116|       |#else
  117|       |    int mutex_type = PTHREAD_MUTEX_DEFAULT;
  118|       |#endif
  119|       |
  120|  32.5k|    int ret = 0;
  121|  32.5k|    pthread_mutexattr_t attr;
  122|  32.5k|    ret = pthread_mutexattr_init(&attr);
  123|  32.5k|    if (ret != 0)
  ------------------
  |  Branch (123:9): [True: 0, False: 32.5k]
  ------------------
  124|      0|        return ret;
  125|       |
  126|  32.5k|    pthread_mutexattr_settype(&attr, mutex_type);
  127|  32.5k|    ret = pthread_mutex_init(mutex, &attr);
  128|  32.5k|    pthread_mutexattr_destroy(&attr);
  129|  32.5k|    mp_assert(!ret);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (129:5): [True: 32.5k, False: 0]
  ------------------
  130|  32.5k|    return ret;
  131|  32.5k|}

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

audio_update_volume:
  187|  32.5k|{
  188|  32.5k|    struct ao_chain *ao_c = mpctx->ao_chain;
  189|  32.5k|    if (!ao_c || !ao_c->ao)
  ------------------
  |  Branch (189:9): [True: 32.5k, False: 0]
  |  Branch (189:18): [True: 0, False: 0]
  ------------------
  190|  32.5k|        return;
  191|       |
  192|      0|    float gain = audio_get_gain(mpctx);
  193|      0|    ao_set_gain(ao_c->ao, gain);
  194|      0|}
update_playback_speed:
  198|  32.5k|{
  199|  32.5k|    mpctx->audio_speed = mpctx->opts->playback_speed * mpctx->speed_factor_a;
  200|  32.5k|    mpctx->video_speed = mpctx->opts->playback_speed * mpctx->speed_factor_v;
  201|       |
  202|  32.5k|    update_speed_filters(mpctx);
  203|  32.5k|}
reset_audio_state:
  231|  32.5k|{
  232|  32.5k|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (232:9): [True: 0, False: 32.5k]
  ------------------
  233|      0|        ao_chain_reset_state(mpctx->ao_chain);
  234|      0|        struct track *t = mpctx->ao_chain->track;
  235|      0|        if (t && t->dec)
  ------------------
  |  Branch (235:13): [True: 0, False: 0]
  |  Branch (235:18): [True: 0, False: 0]
  ------------------
  236|      0|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  237|      0|    }
  238|  32.5k|    mpctx->audio_status = mpctx->ao_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (238:27): [True: 0, False: 32.5k]
  ------------------
  239|  32.5k|    mpctx->delay = 0;
  240|  32.5k|}
uninit_audio_out:
  243|   130k|{
  244|   130k|    struct ao_chain *ao_c = mpctx->ao_chain;
  245|   130k|    if (ao_c) {
  ------------------
  |  Branch (245:9): [True: 0, False: 130k]
  ------------------
  246|      0|        ao_c->ao_queue = NULL;
  247|      0|        TA_FREEP(&ao_c->queue_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]
  |  |  ------------------
  ------------------
  248|      0|        ao_c->ao = NULL;
  249|      0|    }
  250|   130k|    if (mpctx->ao) {
  ------------------
  |  Branch (250:9): [True: 0, False: 130k]
  ------------------
  251|       |        // Note: with gapless_audio, stop_play is not correctly set
  252|      0|        if ((mpctx->opts->gapless_audio || mpctx->stop_play == AT_END_OF_FILE) &&
  ------------------
  |  Branch (252:14): [True: 0, False: 0]
  |  Branch (252:44): [True: 0, False: 0]
  ------------------
  253|      0|            ao_is_playing(mpctx->ao) && !get_internal_paused(mpctx))
  ------------------
  |  Branch (253:13): [True: 0, False: 0]
  |  Branch (253:41): [True: 0, False: 0]
  ------------------
  254|      0|        {
  255|      0|            MP_VERBOSE(mpctx, "draining left over audio\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__)
  |  |  ------------------
  ------------------
  256|      0|            ao_drain(mpctx->ao);
  257|      0|        }
  258|      0|        ao_uninit(mpctx->ao);
  259|       |
  260|      0|        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  261|      0|    }
  262|   130k|    mpctx->ao = NULL;
  263|       |    TA_FREEP(&mpctx->ao_filter_fmt);
  ------------------
  |  |   81|   130k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|   130k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 130k]
  |  |  ------------------
  ------------------
  264|   130k|}
uninit_audio_chain:
  289|  32.5k|{
  290|  32.5k|    if (mpctx->ao_chain) {
  ------------------
  |  Branch (290:9): [True: 0, False: 32.5k]
  ------------------
  291|      0|        ao_chain_uninit(mpctx->ao_chain);
  292|      0|        mpctx->ao_chain = NULL;
  293|       |
  294|      0|        mpctx->audio_status = STATUS_EOF;
  295|       |
  296|       |        mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL);
  297|      0|    }
  298|  32.5k|}
reinit_audio_chain:
  548|  32.5k|{
  549|  32.5k|    struct track *track = NULL;
  550|  32.5k|    track = mpctx->current_track[0][STREAM_AUDIO];
  551|  32.5k|    if (!track || !track->stream) {
  ------------------
  |  Branch (551:9): [True: 32.5k, False: 0]
  |  Branch (551:19): [True: 0, False: 0]
  ------------------
  552|  32.5k|        if (!mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (552:13): [True: 32.5k, False: 0]
  ------------------
  553|  32.5k|            uninit_audio_out(mpctx);
  554|  32.5k|        error_on_track(mpctx, track);
  555|  32.5k|        return;
  556|  32.5k|    }
  557|      0|    reinit_audio_chain_src(mpctx, track);
  558|      0|}
written_audio_pts:
  653|  32.5k|{
  654|  32.5k|    return mpctx->ao_chain ? mpctx->ao_chain->last_out_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|  32.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (654:12): [True: 0, False: 32.5k]
  ------------------
  655|  32.5k|}
playing_audio_pts:
  660|  32.5k|{
  661|  32.5k|    double pts = written_audio_pts(mpctx);
  662|  32.5k|    if (pts == MP_NOPTS_VALUE || !mpctx->ao)
  ------------------
  |  |   39|  65.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (662:9): [True: 32.5k, False: 0]
  |  Branch (662:34): [True: 0, False: 0]
  ------------------
  663|  32.5k|        return pts;
  664|      0|    return pts - mpctx->audio_speed * ao_get_delay(mpctx->ao);
  665|  32.5k|}
reload_audio_output:
  787|  32.5k|{
  788|  32.5k|    if (!mpctx->ao)
  ------------------
  |  Branch (788:9): [True: 32.5k, False: 0]
  ------------------
  789|  32.5k|        return;
  790|       |
  791|      0|    ao_reset(mpctx->ao);
  792|      0|    uninit_audio_out(mpctx);
  793|      0|    reinit_audio_filters(mpctx); // mostly to issue refresh seek
  794|       |
  795|      0|    struct ao_chain *ao_c = mpctx->ao_chain;
  796|       |
  797|      0|    if (ao_c) {
  ------------------
  |  Branch (797:9): [True: 0, False: 0]
  ------------------
  798|      0|        reset_audio_state(mpctx);
  799|      0|        mp_output_chain_reset_harder(ao_c->filter);
  800|      0|    }
  801|       |
  802|       |    // Whether we can use spdif might have changed. If we failed to use spdif
  803|       |    // in the previous initialization, try it with spdif again (we'll fallback
  804|       |    // to PCM again if necessary).
  805|      0|    if (ao_c && ao_c->track) {
  ------------------
  |  Branch (805:9): [True: 0, False: 0]
  |  Branch (805:17): [True: 0, False: 0]
  ------------------
  806|      0|        struct mp_decoder_wrapper *dec = ao_c->track->dec;
  807|      0|        if (dec && ao_c->spdif_failed) {
  ------------------
  |  Branch (807:13): [True: 0, False: 0]
  |  Branch (807:20): [True: 0, False: 0]
  ------------------
  808|      0|            ao_c->spdif_passthrough = true;
  809|      0|            ao_c->spdif_failed = false;
  810|      0|            mp_decoder_wrapper_set_spdif_flag(ao_c->track->dec, true);
  811|      0|            if (!mp_decoder_wrapper_reinit(dec)) {
  ------------------
  |  Branch (811:17): [True: 0, False: 0]
  ------------------
  812|      0|                MP_ERR(mpctx, "Error reinitializing audio.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  813|      0|                error_on_track(mpctx, ao_c->track);
  814|      0|            }
  815|      0|        }
  816|      0|    }
  817|       |
  818|      0|    mp_wakeup_core(mpctx);
  819|      0|}
fill_audio_out_buffers:
  905|   909k|{
  906|   909k|    struct MPOpts *opts = mpctx->opts;
  907|       |
  908|   909k|    if (mpctx->ao && ao_query_and_reset_events(mpctx->ao, AO_EVENT_RELOAD))
  ------------------
  |  Branch (908:9): [True: 0, False: 909k]
  |  Branch (908:22): [True: 0, False: 0]
  ------------------
  909|      0|        reload_audio_output(mpctx);
  910|       |
  911|   909k|    update_throttle(mpctx);
  912|       |
  913|   909k|    struct ao_chain *ao_c = mpctx->ao_chain;
  914|   909k|    if (!ao_c)
  ------------------
  |  Branch (914:9): [True: 909k, False: 0]
  ------------------
  915|   909k|        return;
  916|       |
  917|      0|    if (ao_c->filter->failed_output_conversion) {
  ------------------
  |  Branch (917:9): [True: 0, False: 0]
  ------------------
  918|      0|        error_on_track(mpctx, ao_c->track);
  919|      0|        return;
  920|      0|    }
  921|       |
  922|      0|    if (ao_c->filter->ao_needs_update) {
  ------------------
  |  Branch (922:9): [True: 0, False: 0]
  ------------------
  923|      0|        if (reinit_audio_filters_and_output(mpctx) < 0)
  ------------------
  |  Branch (923:13): [True: 0, False: 0]
  ------------------
  924|      0|            return;
  925|      0|    }
  926|       |
  927|      0|    if (mpctx->vo_chain && ao_c->track && ao_c->track->dec &&
  ------------------
  |  Branch (927:9): [True: 0, False: 0]
  |  Branch (927:28): [True: 0, False: 0]
  |  Branch (927:43): [True: 0, False: 0]
  ------------------
  928|      0|        mp_decoder_wrapper_get_pts_reset(ao_c->track->dec))
  ------------------
  |  Branch (928:9): [True: 0, False: 0]
  ------------------
  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|      0|    if (mpctx->audio_status == STATUS_SYNCING) {
  ------------------
  |  Branch (935:9): [True: 0, False: 0]
  ------------------
  936|      0|        double pts;
  937|      0|        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|      0|        if (mpctx->ao && ao_is_playing(mpctx->ao) &&
  ------------------
  |  Branch (944:13): [True: 0, False: 0]
  |  Branch (944:26): [True: 0, False: 0]
  ------------------
  945|      0|            mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (945:13): [True: 0, False: 0]
  ------------------
  946|      0|            MP_VERBOSE(mpctx, "blocked, waiting for old audio to play\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  947|      0|            ok = false;
  948|      0|        }
  949|       |
  950|      0|        if (ao_c->start_pts_known != ok || ao_c->start_pts != pts) {
  ------------------
  |  Branch (950:13): [True: 0, False: 0]
  |  Branch (950:44): [True: 0, False: 0]
  ------------------
  951|      0|            ao_c->start_pts_known = ok;
  952|      0|            ao_c->start_pts = pts;
  953|      0|            mp_filter_wakeup(ao_c->ao_filter);
  954|      0|        }
  955|       |
  956|      0|        if (ao_c->ao && mp_async_queue_is_full(ao_c->ao_queue)) {
  ------------------
  |  Branch (956:13): [True: 0, False: 0]
  |  Branch (956:25): [True: 0, False: 0]
  ------------------
  957|      0|            mpctx->audio_status = STATUS_READY;
  958|      0|            mp_wakeup_core(mpctx);
  959|      0|            MP_VERBOSE(mpctx, "audio ready\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__)
  |  |  ------------------
  ------------------
  960|      0|        } else if (ao_c->out_eof) {
  ------------------
  |  Branch (960:20): [True: 0, False: 0]
  ------------------
  961|       |            // Force playback start early.
  962|      0|            mpctx->audio_status = STATUS_READY;
  963|      0|            mp_wakeup_core(mpctx);
  964|      0|            MP_VERBOSE(mpctx, "audio ready (and EOF)\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__)
  |  |  ------------------
  ------------------
  965|      0|        }
  966|      0|    }
  967|       |
  968|      0|    if (ao_c->ao && !ao_is_playing(ao_c->ao) && !ao_c->underrun &&
  ------------------
  |  Branch (968:9): [True: 0, False: 0]
  |  Branch (968:21): [True: 0, False: 0]
  |  Branch (968:49): [True: 0, False: 0]
  ------------------
  969|      0|        (mpctx->audio_status == STATUS_PLAYING ||
  ------------------
  |  Branch (969:10): [True: 0, False: 0]
  ------------------
  970|      0|         mpctx->audio_status == STATUS_DRAINING))
  ------------------
  |  Branch (970:10): [True: 0, False: 0]
  ------------------
  971|      0|    {
  972|       |        // Should be playing, but somehow isn't.
  973|       |
  974|      0|        if (ao_c->out_eof && !mp_async_queue_get_frames(ao_c->ao_queue)) {
  ------------------
  |  Branch (974:13): [True: 0, False: 0]
  |  Branch (974:30): [True: 0, False: 0]
  ------------------
  975|      0|            MP_VERBOSE(mpctx, "AO signaled EOF (while in state %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__)
  |  |  ------------------
  ------------------
  976|      0|                       mp_status_str(mpctx->audio_status));
  977|      0|            mpctx->audio_status = STATUS_EOF;
  978|      0|            mp_wakeup_core(mpctx);
  979|       |            // stops untimed AOs, stops pull AOs from streaming silence
  980|      0|            ao_reset(ao_c->ao);
  981|      0|        } 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|      0|    }
  999|       |
 1000|      0|    if (mpctx->audio_status == STATUS_PLAYING && ao_c->out_eof) {
  ------------------
  |  Branch (1000:9): [True: 0, False: 0]
  |  Branch (1000:50): [True: 0, False: 0]
  ------------------
 1001|      0|        mpctx->audio_status = STATUS_DRAINING;
 1002|      0|        MP_VERBOSE(mpctx, "audio draining\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__)
  |  |  ------------------
  ------------------
 1003|      0|        mp_wakeup_core(mpctx);
 1004|      0|    }
 1005|       |
 1006|      0|    if (mpctx->audio_status == STATUS_DRAINING) {
  ------------------
  |  Branch (1006:9): [True: 0, False: 0]
  ------------------
 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|      0|        if (!ao_c->ao || (!ao_is_playing(ao_c->ao) || opts->gapless_audio))
  ------------------
  |  Branch (1009:13): [True: 0, False: 0]
  |  Branch (1009:27): [True: 0, False: 0]
  |  Branch (1009:55): [True: 0, False: 0]
  ------------------
 1010|      0|        {
 1011|      0|            MP_VERBOSE(mpctx, "audio EOF reached\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__)
  |  |  ------------------
  ------------------
 1012|      0|            mpctx->audio_status = STATUS_EOF;
 1013|      0|            mp_wakeup_core(mpctx);
 1014|      0|        }
 1015|      0|    }
 1016|       |
 1017|      0|    if (mpctx->restart_complete)
  ------------------
  |  Branch (1017:9): [True: 0, False: 0]
  ------------------
 1018|      0|        audio_start_ao(mpctx); // in case it got delayed
 1019|      0|}
audio.c:update_speed_filters:
   52|  32.5k|{
   53|  32.5k|    struct ao_chain *ao_c = mpctx->ao_chain;
   54|  32.5k|    if (!ao_c)
  ------------------
  |  Branch (54:9): [True: 32.5k, False: 0]
  ------------------
   55|  32.5k|        return;
   56|       |
   57|      0|    double pitch = mpctx->opts->playback_pitch;
   58|      0|    double speed = mpctx->opts->playback_speed;
   59|      0|    double resample = mpctx->speed_factor_a;
   60|      0|    double drop = 1.0;
   61|       |
   62|      0|    if (!mpctx->opts->pitch_correction) {
  ------------------
  |  Branch (62:9): [True: 0, False: 0]
  ------------------
   63|      0|        resample *= speed;
   64|      0|        speed = 1.0;
   65|      0|    }
   66|       |
   67|      0|    int video_sync = mpctx->display_sync_active ?
  ------------------
  |  Branch (67:22): [True: 0, False: 0]
  ------------------
   68|      0|        mpctx->video_out->opts->video_sync : VS_NONE;
   69|      0|    switch (video_sync) {
   70|      0|        case VS_DISP_ADROP:
  ------------------
  |  Branch (70:9): [True: 0, False: 0]
  ------------------
   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: 0]
  ------------------
   76|      0|            speed = mpctx->audio_speed / pitch;
   77|      0|            resample = pitch;
   78|      0|            break;
   79|      0|        default:
  ------------------
  |  Branch (79:9): [True: 0, False: 0]
  ------------------
   80|      0|            resample *= pitch;
   81|      0|            speed /= pitch;
   82|      0|            break;
   83|      0|    }
   84|       |
   85|      0|    mp_output_chain_set_audio_speed(ao_c->filter, speed, resample, drop);
   86|      0|}
audio.c:update_throttle:
  670|   909k|{
  671|   909k|    struct ao_chain *ao_c = mpctx->ao_chain;
  672|   909k|    bool new_throttle = mpctx->audio_status == STATUS_PLAYING &&
  ------------------
  |  Branch (672:25): [True: 0, False: 909k]
  ------------------
  673|      0|                        mpctx->delay > 0 && ao_c && ao_c->ao &&
  ------------------
  |  Branch (673:25): [True: 0, False: 0]
  |  Branch (673:45): [True: 0, False: 0]
  |  Branch (673:53): [True: 0, False: 0]
  ------------------
  674|      0|                        ao_untimed(ao_c->ao) &&
  ------------------
  |  Branch (674:25): [True: 0, False: 0]
  ------------------
  675|      0|                        mpctx->video_status != STATUS_EOF;
  ------------------
  |  Branch (675:25): [True: 0, False: 0]
  ------------------
  676|   909k|    if (ao_c && new_throttle != ao_c->untimed_throttle) {
  ------------------
  |  Branch (676:9): [True: 0, False: 909k]
  |  Branch (676:17): [True: 0, False: 0]
  ------------------
  677|      0|        ao_c->untimed_throttle = new_throttle;
  678|      0|        mp_wakeup_core(mpctx);
  679|      0|        mp_filter_wakeup(ao_c->ao_filter);
  680|      0|    }
  681|   909k|}

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

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

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

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

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

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

mp_abort_playback_async:
   73|  32.5k|{
   74|  32.5k|    mp_cancel_trigger(mpctx->playback_abort);
   75|       |
   76|  32.5k|    mp_mutex_lock(&mpctx->abort_lock);
  ------------------
  |  |  134|  32.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
   77|       |
   78|  32.5k|    for (int n = 0; n < mpctx->num_abort_list; n++) {
  ------------------
  |  Branch (78:21): [True: 0, False: 32.5k]
  ------------------
   79|      0|        struct mp_abort_entry *abort = mpctx->abort_list[n];
   80|      0|        if (abort->coupled_to_playback)
  ------------------
  |  Branch (80:13): [True: 0, False: 0]
  ------------------
   81|      0|            mp_abort_trigger_locked(mpctx, abort);
   82|      0|    }
   83|       |
   84|  32.5k|    mp_mutex_unlock(&mpctx->abort_lock);
  ------------------
  |  |  136|  32.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
   85|  32.5k|}
track_is_visible:
  318|  79.1k|{
  319|  79.1k|    if (!track_in_current_edition(mpctx, track))
  ------------------
  |  Branch (319:9): [True: 0, False: 79.1k]
  ------------------
  320|      0|        return false;
  321|  79.1k|    if (track->dependent_track && !mpctx->opts->show_dependent_tracks)
  ------------------
  |  Branch (321:9): [True: 0, False: 79.1k]
  |  Branch (321:35): [True: 0, False: 0]
  ------------------
  322|      0|        return false;
  323|  79.1k|    return true;
  324|  79.1k|}
print_track_list:
  327|  32.5k|{
  328|  32.5k|    if (mpctx->opts->term_show_tracks == 2)
  ------------------
  |  Branch (328:9): [True: 0, False: 32.5k]
  ------------------
  329|      0|        return;
  330|  32.5k|    if (msg)
  ------------------
  |  Branch (330:9): [True: 0, False: 32.5k]
  ------------------
  331|  32.5k|        MP_INFO(mpctx, "%s\n", msg);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  332|   130k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (332:21): [True: 97.5k, False: 32.5k]
  ------------------
  333|   216k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (333:25): [True: 118k, False: 97.5k]
  ------------------
  334|   118k|            struct track *track = mpctx->tracks[n];
  335|   118k|            if (track->type != t || !track_is_visible(mpctx, track))
  ------------------
  |  Branch (335:17): [True: 79.0k, False: 39.5k]
  |  Branch (335:37): [True: 0, False: 39.5k]
  ------------------
  336|  79.0k|                continue;
  337|  39.5k|            if (mpctx->opts->term_show_tracks == 1 && !track->selected)
  ------------------
  |  Branch (337:17): [True: 0, False: 39.5k]
  |  Branch (337:55): [True: 0, False: 0]
  ------------------
  338|      0|                continue;
  339|       |            // Indent tracks after messages like "Tracks switched" and
  340|       |            // "Playing:".
  341|  39.5k|            print_stream(mpctx, track, msg ||
  ------------------
  |  Branch (341:40): [True: 0, False: 39.5k]
  ------------------
  342|  39.5k|                         mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (342:26): [True: 0, False: 39.5k]
  ------------------
  343|  39.5k|                         mpctx->playing->playlist_path);
  ------------------
  |  Branch (343:26): [True: 0, False: 39.5k]
  ------------------
  344|  39.5k|        }
  345|  97.5k|    }
  346|  32.5k|}
update_demuxer_properties:
  349|   941k|{
  350|   941k|    struct demuxer *demuxer = mpctx->demuxer;
  351|   941k|    if (!demuxer)
  ------------------
  |  Branch (351:9): [True: 0, False: 941k]
  ------------------
  352|      0|        return;
  353|   941k|    demux_update(demuxer, get_current_time(mpctx));
  354|   941k|    int events = demuxer->events;
  355|   941k|    if ((events & DEMUX_EVENT_INIT) && demuxer->num_editions > 1 &&
  ------------------
  |  Branch (355:9): [True: 32.5k, False: 909k]
  |  Branch (355:40): [True: 0, False: 32.5k]
  ------------------
  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|   941k|    struct demuxer *tracks = mpctx->demuxer;
  376|   941k|    if (tracks->events & DEMUX_EVENT_STREAMS) {
  ------------------
  |  Branch (376:9): [True: 32.5k, False: 909k]
  ------------------
  377|  32.5k|        int num_old_tracks = mpctx->num_tracks;
  378|  32.5k|        add_demuxer_tracks(mpctx, tracks);
  379|  32.5k|        tracks->events &= ~DEMUX_EVENT_STREAMS;
  380|       |
  381|       |        // Streams surfaced after play_current_file's selection phase (e.g.
  382|       |        // disc-nav playlist hop, or lavf identifying a PES stream only once
  383|       |        // its first packet arrives) wouldn't otherwise get auto-selected.
  384|       |        // Only such a stream may claim a free slot, one that disc navigation
  385|       |        // or a failed decoder emptied stays empty.
  386|  32.5k|        if (mpctx->playback_initialized && mpctx->opts->stream_auto_sel) {
  ------------------
  |  Branch (386:13): [True: 0, False: 32.5k]
  |  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|  32.5k|        print_track_list(mpctx, NULL);
  407|  32.5k|    }
  408|   941k|    if (events & DEMUX_EVENT_METADATA) {
  ------------------
  |  Branch (408:9): [True: 32.5k, False: 909k]
  ------------------
  409|  32.5k|        struct mp_tags *info =
  410|  32.5k|            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|  32.5k|        struct mp_tags *prev = mpctx->filtered_tags;
  413|  32.5k|        int n_prev = 0;
  414|  32.5k|        bool had_output = false;
  415|  32.5k|        for (int n = 0; n < info->num_keys; n++) {
  ------------------
  |  Branch (415:25): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|        talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  445|  32.5k|        mpctx->filtered_tags = info;
  446|  32.5k|        mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL);
  447|  32.5k|    }
  448|   941k|    if (events & DEMUX_EVENT_DURATION)
  ------------------
  |  Branch (448:9): [True: 93.3k, False: 848k]
  ------------------
  449|  93.3k|        mp_notify(mpctx, MP_EVENT_DURATION_UPDATE, NULL);
  450|   941k|    if (events & DEMUX_EVENT_CODEC)
  ------------------
  |  Branch (450:9): [True: 0, False: 941k]
  ------------------
  451|      0|        mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  452|   941k|    if (events & DEMUX_EVENT_LISTS) {
  ------------------
  |  Branch (452:9): [True: 0, False: 941k]
  ------------------
  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|   941k|    demuxer->events = 0;
  476|   941k|}
reselect_demux_stream:
  483|  39.5k|{
  484|  39.5k|    if (!track->stream)
  ------------------
  |  Branch (484:9): [True: 0, False: 39.5k]
  ------------------
  485|      0|        return;
  486|  39.5k|    double pts = get_current_time(mpctx);
  487|  39.5k|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  39.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (487:9): [True: 39.5k, False: 0]
  ------------------
  488|  39.5k|        pts += get_track_seek_offset(mpctx, track);
  489|  39.5k|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (489:13): [True: 6.72k, False: 32.8k]
  ------------------
  490|  6.72k|            pts -= 10.0;
  491|  39.5k|    }
  492|  39.5k|    if (refresh_only)
  ------------------
  |  Branch (492:9): [True: 0, False: 39.5k]
  ------------------
  493|      0|        demuxer_refresh_track(track->demuxer, track->stream, pts);
  494|  39.5k|    else
  495|  39.5k|        demuxer_select_track(track->demuxer, track->stream, pts, track->selected);
  496|  39.5k|}
add_demuxer_tracks:
  556|  65.0k|{
  557|   130k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++)
  ------------------
  |  Branch (557:21): [True: 65.0k, False: 65.0k]
  ------------------
  558|  65.0k|        add_stream_track(mpctx, demuxer, demux_get_stream(demuxer, n));
  559|  65.0k|}
select_default_track:
  677|   130k|{
  678|   130k|    struct MPOpts *opts = mpctx->opts;
  679|   130k|    int tid = opts->stream_id[order][type];
  680|   130k|    const struct demuxer *demuxer = mpctx->demuxer;
  681|   130k|    if (tid == -2)
  ------------------
  |  Branch (681:9): [True: 32.5k, False: 97.5k]
  ------------------
  682|  32.5k|        return NULL;
  683|  97.5k|    char **langs = process_langs(opts->stream_lang[type]);
  684|  97.5k|    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|  97.5k|    if (type == STREAM_SUB && (!langs || !strcmp(langs[0], "")) && opts->subs_match_os_language) {
  ------------------
  |  Branch (686:9): [True: 32.5k, False: 65.0k]
  |  Branch (686:32): [True: 32.5k, False: 0]
  |  Branch (686:42): [True: 0, False: 0]
  |  Branch (686:68): [True: 32.5k, False: 0]
  ------------------
  687|  32.5k|        talloc_free(langs);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  688|  32.5k|        langs = add_os_langs();
  689|  32.5k|        os_langs = true;
  690|  32.5k|    }
  691|  97.5k|    const char *audio_lang = mpctx->current_track[0][STREAM_AUDIO] ?
  ------------------
  |  Branch (691:30): [True: 0, False: 97.5k]
  ------------------
  692|      0|                             mpctx->current_track[0][STREAM_AUDIO]->lang :
  693|  97.5k|                             NULL;
  694|  97.5k|    bool sub = type == STREAM_SUB;
  695|  97.5k|    int *preferred_programs = NULL;
  696|  97.5k|    int num_preferred_programs = 0;
  697|  97.5k|    struct track *cvt = mpctx->current_track[0][STREAM_VIDEO];
  698|  97.5k|    bool video_has_programs = cvt && cvt->stream && cvt->stream->num_program_ids;
  ------------------
  |  Branch (698:31): [True: 65.0k, False: 32.5k]
  |  Branch (698:38): [True: 65.0k, False: 0]
  |  Branch (698:53): [True: 0, False: 65.0k]
  ------------------
  699|  97.5k|    bool no_edition_mapping = !demuxer || !demuxer->edition_is_track_mapping ||
  ------------------
  |  Branch (699:31): [True: 0, False: 97.5k]
  |  Branch (699:43): [True: 97.5k, False: 0]
  ------------------
  700|      0|                              demuxer->num_editions <= 1;
  ------------------
  |  Branch (700:31): [True: 0, False: 0]
  ------------------
  701|  97.5k|    if (type != STREAM_VIDEO && video_has_programs && no_edition_mapping) {
  ------------------
  |  Branch (701:9): [True: 65.0k, False: 32.5k]
  |  Branch (701:33): [True: 0, False: 65.0k]
  |  Branch (701:55): [True: 0, False: 0]
  ------------------
  702|      0|        preferred_programs = cvt->stream->program_ids;
  703|      0|        num_preferred_programs = cvt->stream->num_program_ids;
  704|      0|    }
  705|  97.5k|    struct track *pick = NULL;
  706|   216k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (706:21): [True: 118k, False: 97.5k]
  ------------------
  707|   118k|        struct track *track = mpctx->tracks[n];
  708|   118k|        if (track->type != type)
  ------------------
  |  Branch (708:13): [True: 79.1k, False: 39.5k]
  ------------------
  709|  79.1k|            continue;
  710|  39.5k|        if (!track_is_visible(mpctx, track))
  ------------------
  |  Branch (710:13): [True: 0, False: 39.5k]
  ------------------
  711|      0|            continue;
  712|  39.5k|        if (track->user_tid == tid) {
  ------------------
  |  Branch (712:13): [True: 0, False: 39.5k]
  ------------------
  713|      0|            pick = track;
  714|      0|            goto cleanup;
  715|      0|        }
  716|  39.5k|        if (track->no_auto_select || track->dec_failed)
  ------------------
  |  Branch (716:13): [True: 329, False: 39.2k]
  |  Branch (716:38): [True: 25, False: 39.2k]
  ------------------
  717|    354|            continue;
  718|  39.2k|        if (!opts->autoload_files && track->is_external)
  ------------------
  |  Branch (718:13): [True: 0, False: 39.2k]
  |  Branch (718:38): [True: 0, False: 0]
  ------------------
  719|      0|            continue;
  720|       |        // Prefer tracks from the same programs as the selected video.
  721|  39.2k|        bool in_program = !num_preferred_programs || track->is_external ||
  ------------------
  |  Branch (721:27): [True: 39.2k, 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|  39.2k|        for (int i = 0; i < num_preferred_programs && !in_program; i++)
  ------------------
  |  Branch (723:25): [True: 0, False: 39.2k]
  |  Branch (723:55): [True: 0, False: 0]
  ------------------
  724|      0|            in_program = track_has_program(track, preferred_programs[i]);
  725|  39.2k|        if (!in_program)
  ------------------
  |  Branch (725:13): [True: 0, False: 39.2k]
  ------------------
  726|      0|            continue;
  727|  39.2k|        if (duplicate_track(mpctx, order, type, track))
  ------------------
  |  Branch (727:13): [True: 0, False: 39.2k]
  ------------------
  728|      0|            continue;
  729|  39.2k|        if (sub) {
  ------------------
  |  Branch (729:13): [True: 6.69k, False: 32.5k]
  ------------------
  730|       |            // Subtitle specific auto-selecting crap.
  731|  6.69k|            bool audio_matches = mp_match_lang((char *[]){ (char *)audio_lang, NULL }, track->lang) > 0;
  732|  6.69k|            bool forced = track->forced_track && (opts->subs_fallback_forced == 2 ||
  ------------------
  |  Branch (732:27): [True: 0, False: 6.69k]
  |  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|  6.69k|            bool lang_match = !os_langs && mp_match_lang(langs, track->lang) > 0;
  ------------------
  |  Branch (734:31): [True: 0, False: 6.69k]
  |  Branch (734:44): [True: 0, False: 0]
  ------------------
  735|  6.69k|            bool subs_fallback = (track->is_external && !track->no_default) || opts->subs_fallback == 2 ||
  ------------------
  |  Branch (735:35): [True: 6.69k, False: 0]
  |  Branch (735:57): [True: 6.69k, 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|  6.69k|            bool subs_matching_audio = (!mp_match_lang(langs, audio_lang) || opts->subs_with_matching_audio == 2 ||
  ------------------
  |  Branch (737:41): [True: 6.69k, 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|  6.69k|            if (!subs_matching_audio)
  ------------------
  |  Branch (739:17): [True: 0, False: 6.69k]
  ------------------
  740|      0|                continue;
  741|  6.69k|            if (!forced && !lang_match && !subs_fallback)
  ------------------
  |  Branch (741:17): [True: 6.69k, False: 0]
  |  Branch (741:28): [True: 6.69k, False: 0]
  |  Branch (741:43): [True: 0, False: 6.69k]
  ------------------
  742|      0|                continue;
  743|  6.69k|            track->forced_select = forced;
  744|  6.69k|        }
  745|  39.2k|        if (!pick || compare_track(track, pick, langs, os_langs, mpctx->opts)) {
  ------------------
  |  Branch (745:13): [True: 39.2k, False: 13]
  |  Branch (745:22): [True: 0, False: 13]
  ------------------
  746|  39.2k|            pick = track;
  747|  39.2k|        }
  748|  39.2k|    }
  749|       |
  750|  97.5k|    if (pick && pick->attached_picture && !mpctx->opts->audio_display)
  ------------------
  |  Branch (750:9): [True: 39.2k, False: 58.3k]
  |  Branch (750:17): [True: 0, False: 39.2k]
  |  Branch (750:43): [True: 0, False: 0]
  ------------------
  751|      0|        pick = NULL;
  752|  97.5k|cleanup:
  753|  97.5k|    talloc_free(langs);
  ------------------
  |  |   47|  97.5k|#define talloc_free                     ta_free
  ------------------
  754|  97.5k|    return pick;
  755|  97.5k|}
mark_track_selection:
  801|     20|{
  802|     20|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|     20|#define mp_assert assert
  ------------------
  |  Branch (802:5): [True: 20, False: 0]
  |  Branch (802:5): [True: 20, False: 0]
  ------------------
  803|     20|    mpctx->opts->stream_id[order][type] = value;
  804|     20|    m_config_notify_change_opt_ptr(mpctx->mconfig,
  805|     20|                                   &mpctx->opts->stream_id[order][type]);
  806|     20|}
mp_switch_track_n:
  810|     25|{
  811|     25|    mp_assert(!track || track->type == type);
  ------------------
  |  |   41|     25|#define mp_assert assert
  ------------------
  |  Branch (811:5): [True: 20, False: 5]
  |  Branch (811:5): [True: 5, False: 0]
  ------------------
  812|     25|    mp_assert(type >= 0 && type < STREAM_TYPE_COUNT);
  ------------------
  |  |   41|     25|#define mp_assert assert
  ------------------
  |  Branch (812:5): [True: 25, False: 0]
  |  Branch (812:5): [True: 25, False: 0]
  ------------------
  813|     25|    mp_assert(order >= 0 && order < num_ptracks[type]);
  ------------------
  |  |   41|     25|#define mp_assert assert
  ------------------
  |  Branch (813:5): [True: 25, False: 0]
  |  Branch (813:5): [True: 25, 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|     25|    if (flags & FLAG_MARK_SELECTION)
  ------------------
  |  |  559|     25|#define FLAG_MARK_SELECTION 1
  ------------------
  |  Branch (817:9): [True: 0, False: 25]
  ------------------
  818|      0|        mark_track_selection(mpctx, order, type, track ? track->user_tid : -2);
  ------------------
  |  Branch (818:50): [True: 0, False: 0]
  ------------------
  819|       |
  820|       |    // No decoder should be initialized yet.
  821|     25|    if (!mpctx->demuxer)
  ------------------
  |  Branch (821:9): [True: 0, False: 25]
  ------------------
  822|      0|        return;
  823|       |
  824|     25|    struct track *current = mpctx->current_track[order][type];
  825|     25|    if (track == current)
  ------------------
  |  Branch (825:9): [True: 0, False: 25]
  ------------------
  826|      0|        return;
  827|       |
  828|     25|    if (current && current->sink) {
  ------------------
  |  Branch (828:9): [True: 25, False: 0]
  |  Branch (828:20): [True: 0, False: 25]
  ------------------
  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|     25|    if ((type == STREAM_VIDEO && mpctx->vo_chain && !mpctx->vo_chain->track) ||
  ------------------
  |  Branch (832:10): [True: 0, False: 25]
  |  Branch (832:34): [True: 0, False: 0]
  |  Branch (832:53): [True: 0, False: 0]
  ------------------
  833|     25|        (type == STREAM_AUDIO && mpctx->ao_chain && !mpctx->ao_chain->track))
  ------------------
  |  Branch (833:10): [True: 0, False: 25]
  |  Branch (833:34): [True: 0, False: 0]
  |  Branch (833:53): [True: 0, False: 0]
  ------------------
  834|      0|    {
  835|      0|        MP_ERR(mpctx, "Can't switch away from complex filter output.\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  836|      0|        goto error;
  837|      0|    }
  838|       |
  839|     25|    if (track && track->selected) {
  ------------------
  |  Branch (839:9): [True: 5, False: 20]
  |  Branch (839:18): [True: 0, False: 5]
  ------------------
  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|     25|    if (order == 0) {
  ------------------
  |  Branch (845:9): [True: 25, False: 0]
  ------------------
  846|     25|        if (type == STREAM_VIDEO) {
  ------------------
  |  Branch (846:13): [True: 0, False: 25]
  ------------------
  847|      0|            uninit_video_chain(mpctx);
  848|      0|            if (!track)
  ------------------
  |  Branch (848:17): [True: 0, False: 0]
  ------------------
  849|      0|                handle_force_window(mpctx, true);
  850|     25|        } else if (type == STREAM_AUDIO) {
  ------------------
  |  Branch (850:20): [True: 0, False: 25]
  ------------------
  851|      0|            clear_audio_output_buffers(mpctx);
  852|      0|            uninit_audio_chain(mpctx);
  853|      0|            if (!track)
  ------------------
  |  Branch (853:17): [True: 0, False: 0]
  ------------------
  854|      0|                uninit_audio_out(mpctx);
  855|      0|        }
  856|     25|    }
  857|     25|    if (type == STREAM_SUB)
  ------------------
  |  Branch (857:9): [True: 25, False: 0]
  ------------------
  858|     25|        uninit_sub(mpctx, current);
  859|       |
  860|     25|    if (current) {
  ------------------
  |  Branch (860:9): [True: 25, False: 0]
  ------------------
  861|     25|        current->selected = false;
  862|     25|        reselect_demux_stream(mpctx, current, false);
  863|     25|    }
  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|     25|    if (type == STREAM_VIDEO && order == 0 && !current && track->image) {
  ------------------
  |  Branch (867:9): [True: 0, False: 25]
  |  Branch (867:33): [True: 0, False: 0]
  |  Branch (867:47): [True: 0, False: 0]
  |  Branch (867:59): [True: 0, False: 0]
  ------------------
  868|      0|        for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (868:25): [True: 0, False: 0]
  ------------------
  869|      0|            struct track *sub_track = mpctx->current_track[n][STREAM_SUB];
  870|      0|            if (sub_track && sub_track->d_sub) {
  ------------------
  |  Branch (870:17): [True: 0, False: 0]
  |  Branch (870:30): [True: 0, False: 0]
  ------------------
  871|      0|                sub_control(sub_track->d_sub, SD_CTRL_RESET_SOFT, NULL);
  872|      0|                sub_reset(sub_track->d_sub);
  873|      0|                if (sub_track->selected)
  ------------------
  |  Branch (873:21): [True: 0, False: 0]
  ------------------
  874|      0|                    reselect_demux_stream(mpctx, sub_track, true);
  875|      0|            }
  876|      0|        }
  877|      0|    }
  878|       |
  879|     25|    mpctx->current_track[order][type] = track;
  880|       |
  881|     25|    if (track) {
  ------------------
  |  Branch (881:9): [True: 5, False: 20]
  ------------------
  882|      5|        track->selected = true;
  883|      5|        reselect_demux_stream(mpctx, track, false);
  884|      5|    }
  885|       |
  886|     25|    if (type == STREAM_VIDEO && order == 0) {
  ------------------
  |  Branch (886:9): [True: 0, False: 25]
  |  Branch (886:33): [True: 0, False: 0]
  ------------------
  887|      0|        reinit_video_chain(mpctx);
  888|     25|    } else if (type == STREAM_AUDIO && order == 0) {
  ------------------
  |  Branch (888:16): [True: 0, False: 25]
  |  Branch (888:40): [True: 0, False: 0]
  ------------------
  889|      0|        reinit_audio_chain(mpctx);
  890|     25|    } else if (type == STREAM_SUB && order >= 0 && order <= 2) {
  ------------------
  |  Branch (890:16): [True: 25, False: 0]
  |  Branch (890:38): [True: 25, False: 0]
  |  Branch (890:52): [True: 25, False: 0]
  ------------------
  891|     25|        reinit_sub(mpctx, track);
  892|     25|    }
  893|       |
  894|     25|    mp_notify(mpctx, MP_EVENT_TRACK_SWITCHED, NULL);
  895|     25|    mp_wakeup_core(mpctx);
  896|       |
  897|     25|    talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|     25|#define talloc_free                     ta_free
  ------------------
  898|     25|    mpctx->track_layout_hash = talloc_steal(mpctx, track_layout_hash(mpctx));
  ------------------
  |  |   38|     25|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|     25|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  899|       |
  900|     25|    return;
  901|      0|error:
  902|      0|    mark_track_selection(mpctx, order, type, -1);
  903|      0|}
mp_deselect_track:
  912|     20|{
  913|     20|    if (track && track->selected) {
  ------------------
  |  Branch (913:9): [True: 20, False: 0]
  |  Branch (913:18): [True: 20, False: 0]
  ------------------
  914|     60|        for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (914:25): [True: 40, False: 20]
  ------------------
  915|     40|            if (mpctx->current_track[t][track->type] != track)
  ------------------
  |  Branch (915:17): [True: 20, False: 20]
  ------------------
  916|     20|                continue;
  917|     20|            mp_switch_track_n(mpctx, t, track->type, NULL, 0);
  918|     20|            mark_track_selection(mpctx, t, track->type, -1); // default
  919|     20|        }
  920|     20|    }
  921|     20|}
mp_add_external_file:
  975|  32.5k|{
  976|  32.5k|    struct MPOpts *opts = mpctx->opts;
  977|  32.5k|    if (!filename || mp_cancel_test(cancel))
  ------------------
  |  Branch (977:9): [True: 0, False: 32.5k]
  |  Branch (977:22): [True: 0, False: 32.5k]
  ------------------
  978|      0|        return -1;
  979|       |
  980|  32.5k|    void *unescaped_url = NULL;
  981|  32.5k|    char *disp_filename = filename;
  982|  32.5k|    if (strncmp(disp_filename, "memory://", 9) == 0) {
  ------------------
  |  Branch (982:9): [True: 0, False: 32.5k]
  ------------------
  983|      0|        disp_filename = "memory://"; // avoid noise
  984|  32.5k|    } else if (mp_is_url(bstr0(disp_filename))) {
  ------------------
  |  Branch (984:16): [True: 32.5k, False: 0]
  ------------------
  985|  32.5k|        disp_filename = unescaped_url = mp_url_unescape(NULL, disp_filename);
  986|  32.5k|    }
  987|       |
  988|  32.5k|    struct demuxer_params params = {
  989|  32.5k|        .is_top_level = true,
  990|  32.5k|        .stream_flags = STREAM_ORIGIN_DIRECT,
  ------------------
  |  |   47|  32.5k|#define STREAM_ORIGIN_DIRECT      (1 << 2) // passed from cmdline or loadfile
  ------------------
  991|  32.5k|        .allow_playlist_create = false,
  992|  32.5k|    };
  993|       |
  994|  32.5k|    switch (filter) {
  ------------------
  |  Branch (994:13): [True: 32.5k, False: 0]
  ------------------
  995|  32.5k|    case STREAM_SUB:
  ------------------
  |  Branch (995:5): [True: 32.5k, False: 0]
  ------------------
  996|  32.5k|        params.force_format = opts->sub_demuxer_name;
  997|  32.5k|        break;
  998|      0|    case STREAM_AUDIO:
  ------------------
  |  Branch (998:5): [True: 0, False: 32.5k]
  ------------------
  999|      0|        params.force_format = opts->audio_demuxer_name;
 1000|      0|        break;
 1001|  32.5k|    }
 1002|       |
 1003|  32.5k|    mp_core_unlock(mpctx);
 1004|       |
 1005|  32.5k|    char *path = mp_get_user_path(NULL, mpctx->global, filename);
 1006|  32.5k|    struct demuxer *demuxer =
 1007|  32.5k|        demux_open_url(path, &params, cancel, mpctx->global);
 1008|  32.5k|    talloc_free(path);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1009|       |
 1010|  32.5k|    if (demuxer)
  ------------------
  |  Branch (1010:9): [True: 25.0k, False: 7.50k]
  ------------------
 1011|  25.0k|        enable_demux_thread(mpctx, demuxer);
 1012|       |
 1013|  32.5k|    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|  32.5k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1017:9): [True: 0, False: 32.5k]
  ------------------
 1018|      0|        goto err_out;
 1019|       |
 1020|  32.5k|    if (!demuxer)
  ------------------
  |  Branch (1020:9): [True: 7.50k, False: 25.0k]
  ------------------
 1021|  7.50k|        goto err_out;
 1022|       |
 1023|  25.0k|    if (filter != STREAM_SUB && opts->rebase_start_time)
  ------------------
  |  Branch (1023:9): [True: 0, False: 25.0k]
  |  Branch (1023:33): [True: 0, False: 0]
  ------------------
 1024|      0|        demux_set_ts_offset(demuxer, -demuxer->start_time);
 1025|       |
 1026|  25.0k|    bool has_any = false;
 1027|  66.2k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
  ------------------
  |  Branch (1027:21): [True: 47.9k, False: 18.3k]
  ------------------
 1028|  47.9k|        struct sh_stream *sh = demux_get_stream(demuxer, n);
 1029|  47.9k|        if (sh->type == filter || filter == STREAM_TYPE_COUNT) {
  ------------------
  |  Branch (1029:13): [True: 6.68k, False: 41.2k]
  |  Branch (1029:35): [True: 0, False: 41.2k]
  ------------------
 1030|  6.68k|            has_any = true;
 1031|  6.68k|            break;
 1032|  6.68k|        }
 1033|  47.9k|    }
 1034|       |
 1035|  25.0k|    if (!has_any) {
  ------------------
  |  Branch (1035:9): [True: 18.3k, False: 6.68k]
  ------------------
 1036|  18.3k|        char *tname = mp_tprintf(20, "%s ", stream_type_name(filter));
  ------------------
  |  |  195|  18.3k|    mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__)
  ------------------
 1037|  18.3k|        if (filter == STREAM_TYPE_COUNT)
  ------------------
  |  Branch (1037:13): [True: 0, False: 18.3k]
  ------------------
 1038|      0|            tname = "";
 1039|  18.3k|        MP_ERR(mpctx, "No %sstreams in file %s.\n", tname, disp_filename);
  ------------------
  |  |   89|  18.3k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  18.3k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1040|  18.3k|        goto err_out;
 1041|  18.3k|    }
 1042|       |
 1043|  6.68k|    int first_num = -1;
 1044|  13.7k|    for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
  ------------------
  |  Branch (1044:21): [True: 7.02k, False: 6.68k]
  ------------------
 1045|  7.02k|        struct sh_stream *sh = demux_get_stream(demuxer, n);
 1046|  7.02k|        struct track *t = add_stream_track(mpctx, demuxer, sh);
 1047|  7.02k|        t->is_external = true;
 1048|  7.02k|        if (sh->title && sh->title[0]) {
  ------------------
  |  Branch (1048:13): [True: 0, False: 7.02k]
  |  Branch (1048:26): [True: 0, False: 0]
  ------------------
 1049|      0|            t->title = talloc_strdup(t, sh->title);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1050|  7.02k|        } else {
 1051|  7.02k|            bstr parent = {0};
 1052|  7.02k|            if (mpctx->filename)
  ------------------
  |  Branch (1052:17): [True: 7.02k, False: 0]
  ------------------
 1053|  7.02k|                parent = mp_strip_ext(bstr0(mp_basename(mpctx->filename)));
 1054|  7.02k|            bstr title = bstr0(mp_basename(disp_filename));
 1055|  7.02k|            bstr_eatstart(&title, parent);
 1056|  7.02k|            bstr_eatstart(&title, bstr0("."));
 1057|  7.02k|            if (title.len)
  ------------------
  |  Branch (1057:17): [True: 7.02k, False: 0]
  ------------------
 1058|  7.02k|                t->title = bstrdup0(t, title);
 1059|  7.02k|        }
 1060|  7.02k|        t->external_filename = mp_normalize_user_path(t, mpctx->global, filename);
 1061|  7.02k|        t->no_default = sh->type != filter;
 1062|  7.02k|        t->no_auto_select = t->no_default;
 1063|  7.02k|        t->hearing_impaired_track = flags & TRACK_HEARING_IMPAIRED;
 1064|  7.02k|        t->visual_impaired_track = flags & TRACK_VISUAL_IMPAIRED;
 1065|  7.02k|        t->forced_track = flags & TRACK_FORCED;
 1066|  7.02k|        t->default_track = flags & TRACK_DEFAULT;
 1067|  7.02k|        t->commentary_track = flags & TRACK_COMMENTARY;
 1068|       |        // if we found video, and we are loading cover art, flag as such.
 1069|  7.02k|        t->attached_picture = t->type == STREAM_VIDEO && (flags & TRACK_ATTACHED_PICTURE);
  ------------------
  |  Branch (1069:31): [True: 128, False: 6.89k]
  |  Branch (1069:58): [True: 0, False: 128]
  ------------------
 1070|  7.02k|        if (first_num < 0 && (filter == STREAM_TYPE_COUNT || sh->type == filter))
  ------------------
  |  Branch (1070:13): [True: 6.84k, False: 172]
  |  Branch (1070:31): [True: 0, False: 6.84k]
  |  Branch (1070:62): [True: 6.68k, False: 168]
  ------------------
 1071|  6.68k|            first_num = mpctx->num_tracks - 1;
 1072|  7.02k|    }
 1073|       |
 1074|  6.68k|    mp_cancel_set_parent(demuxer->cancel, mpctx->playback_abort);
 1075|       |
 1076|  6.68k|    talloc_free(unescaped_url);
  ------------------
  |  |   47|  6.68k|#define talloc_free                     ta_free
  ------------------
 1077|  6.68k|    return first_num;
 1078|       |
 1079|  25.8k|err_out:
 1080|  25.8k|    demux_cancel_and_free(demuxer);
 1081|  25.8k|    if (!mp_cancel_test(cancel))
  ------------------
  |  Branch (1081:9): [True: 25.8k, False: 0]
  ------------------
 1082|  25.8k|        MP_ERR(mpctx, "Can not open external file %s.\n", disp_filename);
  ------------------
  |  |   89|  25.8k|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  25.8k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1083|  25.8k|    talloc_free(unescaped_url);
  ------------------
  |  |   47|  25.8k|#define talloc_free                     ta_free
  ------------------
 1084|  25.8k|    return -1;
 1085|  25.0k|}
autoload_external_files:
 1105|  32.5k|{
 1106|  32.5k|    struct MPOpts *opts = mpctx->opts;
 1107|       |
 1108|  32.5k|    if (opts->sub_auto < 0 && opts->audiofile_auto < 0 && opts->coverart_auto < 0)
  ------------------
  |  Branch (1108:9): [True: 0, False: 32.5k]
  |  Branch (1108:31): [True: 0, False: 0]
  |  Branch (1108:59): [True: 0, False: 0]
  ------------------
 1109|      0|        return;
 1110|  32.5k|    if (!opts->autoload_files || strcmp(mpctx->filename, "-") == 0)
  ------------------
  |  Branch (1110:9): [True: 0, False: 32.5k]
  |  Branch (1110:34): [True: 0, False: 32.5k]
  ------------------
 1111|      0|        return;
 1112|       |
 1113|  32.5k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|  32.5k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  32.5k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1114|  32.5k|    struct subfn *list = find_external_files(mpctx->global, mpctx->filename, opts);
 1115|  32.5k|    talloc_steal(tmp, list);
  ------------------
  |  |   38|  32.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  32.5k|#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|  32.5k|    int sc[STREAM_TYPE_COUNT + 1] = {0};
 1120|  72.0k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1120:21): [True: 39.5k, False: 32.5k]
  ------------------
 1121|  39.5k|        mp_assert(mpctx->tracks[n]->type >= 0);
  ------------------
  |  |   41|  39.5k|#define mp_assert assert
  ------------------
  |  Branch (1121:9): [True: 39.5k, False: 0]
  ------------------
 1122|  39.5k|        mp_assert(mpctx->tracks[n]->type <= STREAM_TYPE_COUNT);
  ------------------
  |  |   41|  39.5k|#define mp_assert assert
  ------------------
  |  Branch (1122:9): [True: 39.5k, False: 0]
  ------------------
 1123|  39.5k|        if (!mpctx->tracks[n]->attached_picture)
  ------------------
  |  Branch (1123:13): [True: 39.5k, False: 0]
  ------------------
 1124|  39.5k|            sc[mpctx->tracks[n]->type]++;
 1125|  39.5k|    }
 1126|       |
 1127|  32.5k|    for (int i = 0; list && list[i].fname; i++) {
  ------------------
  |  Branch (1127:21): [True: 32.5k, False: 0]
  |  Branch (1127:29): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    talloc_free(tmp);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1159|  32.5k|}
prepare_playlist:
 1164|  32.5k|{
 1165|  32.5k|    struct MPOpts *opts = mpctx->opts;
 1166|  32.5k|    struct playlist_entry *entry = NULL;
 1167|       |
 1168|  32.5k|    if (overwrite_current)
  ------------------
  |  Branch (1168:9): [True: 0, False: 32.5k]
  ------------------
 1169|      0|        pl->current = NULL;
 1170|       |
 1171|  32.5k|    pl->playlist_completed = false;
 1172|  32.5k|    pl->playlist_started = false;
 1173|       |
 1174|  32.5k|    if (opts->playlist_pos >= 0) {
  ------------------
  |  Branch (1174:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    if (pl->playlist_dir)
  ------------------
  |  Branch (1179:9): [True: 0, False: 32.5k]
  ------------------
 1180|      0|        playlist_set_current(pl);
 1181|       |
 1182|  32.5k|    if (opts->shuffle)
  ------------------
  |  Branch (1182:9): [True: 0, False: 32.5k]
  ------------------
 1183|      0|        playlist_shuffle(pl);
 1184|       |
 1185|  32.5k|    if (opts->merge_files)
  ------------------
  |  Branch (1185:9): [True: 0, False: 32.5k]
  ------------------
 1186|      0|        merge_playlist_files(pl);
 1187|       |
 1188|  32.5k|    if (!pl->current || (!overwrite_current && !entry)) {
  ------------------
  |  Branch (1188:9): [True: 32.5k, False: 0]
  |  Branch (1188:26): [True: 0, False: 0]
  |  Branch (1188:48): [True: 0, False: 0]
  ------------------
 1189|  32.5k|        entry = mp_check_playlist_resume(mpctx, pl);
 1190|  32.5k|        pl->current = overwrite_current || entry ? entry : pl->current;
  ------------------
  |  Branch (1190:23): [True: 0, False: 32.5k]
  |  Branch (1190:44): [True: 0, False: 32.5k]
  ------------------
 1191|  32.5k|    }
 1192|       |
 1193|  32.5k|    if (!pl->current)
  ------------------
  |  Branch (1193:9): [True: 32.5k, False: 0]
  ------------------
 1194|  32.5k|        pl->current = playlist_get_first(pl);
 1195|  32.5k|}
prefetch_next:
 1440|   121k|{
 1441|   121k|    if (!mpctx->opts->prefetch_open || mpctx->open_active)
  ------------------
  |  Branch (1441:9): [True: 121k, False: 0]
  |  Branch (1441:40): [True: 0, False: 0]
  ------------------
 1442|   121k|        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|   974k|{
 1673|   974k|    if (!mpctx->vo_chain || !mpctx->vo_chain->filter)
  ------------------
  |  Branch (1673:9): [True: 0, False: 974k]
  |  Branch (1673:29): [True: 0, False: 974k]
  ------------------
 1674|      0|        return;
 1675|   974k|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
 1676|   974k|    mp_output_chain_set_el_stream(mpctx->vo_chain->filter,
 1677|   974k|        track ? sh_stream_dependent_sibling(track->stream) : NULL);
  ------------------
  |  Branch (1677:9): [True: 974k, False: 0]
  ------------------
 1678|   974k|}
update_lavfi_complex:
 1681|  32.5k|{
 1682|  32.5k|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (1682:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|}
mp_next_file:
 2250|  32.5k|{
 2251|  32.5k|    struct playlist_entry *next = playlist_get_next(mpctx->playlist, direction);
 2252|  32.5k|    if (next && direction < 0 && !force)
  ------------------
  |  Branch (2252:9): [True: 0, False: 32.5k]
  |  Branch (2252:17): [True: 0, False: 0]
  |  Branch (2252:34): [True: 0, False: 0]
  ------------------
 2253|      0|        next->playlist_prev_attempt = true;
 2254|  32.5k|    if (!next && mpctx->opts->loop_times != 1) {
  ------------------
  |  Branch (2254:9): [True: 32.5k, False: 0]
  |  Branch (2254:18): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    return next;
 2284|  32.5k|}
mp_play_files:
 2289|  32.5k|{
 2290|  32.5k|    stats_register_thread_cputime(mpctx->stats, "thread");
 2291|       |
 2292|       |    // Wait for all scripts to load before possibly starting playback.
 2293|  32.5k|    if (!mp_clients_all_initialized(mpctx)) {
  ------------------
  |  Branch (2293:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    mp_msg_set_early_logging(mpctx->global, false);
 2302|       |
 2303|  32.5k|    prepare_playlist(mpctx, mpctx->playlist, false);
 2304|       |
 2305|  65.0k|    for (;;) {
 2306|  65.0k|        idle_loop(mpctx);
 2307|       |
 2308|  65.0k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2308:13): [True: 32.5k, False: 32.5k]
  ------------------
 2309|  32.5k|            break;
 2310|       |
 2311|  32.5k|        if (mpctx->playlist->current)
  ------------------
  |  Branch (2311:13): [True: 32.5k, False: 0]
  ------------------
 2312|  32.5k|            play_current_file(mpctx);
 2313|       |
 2314|  32.5k|        if (mpctx->stop_play == PT_QUIT)
  ------------------
  |  Branch (2314:13): [True: 0, False: 32.5k]
  ------------------
 2315|      0|            break;
 2316|       |
 2317|  32.5k|        struct playlist_entry *new_entry = NULL;
 2318|  32.5k|        if (mpctx->stop_play == PT_NEXT_ENTRY || mpctx->stop_play == PT_ERROR ||
  ------------------
  |  Branch (2318:13): [True: 0, False: 32.5k]
  |  Branch (2318:50): [True: 0, False: 32.5k]
  ------------------
 2319|  32.5k|            mpctx->stop_play == AT_END_OF_FILE)
  ------------------
  |  Branch (2319:13): [True: 32.5k, False: 0]
  ------------------
 2320|  32.5k|        {
 2321|  32.5k|            new_entry = mp_next_file(mpctx, +1, false, true);
 2322|  32.5k|        } else if (mpctx->stop_play == PT_CURRENT_ENTRY) {
  ------------------
  |  Branch (2322:20): [True: 0, False: 0]
  ------------------
 2323|      0|            new_entry = mpctx->playlist->current;
 2324|      0|        }
 2325|       |
 2326|  32.5k|        if (!new_entry)
  ------------------
  |  Branch (2326:13): [True: 32.5k, False: 0]
  ------------------
 2327|  32.5k|            mpctx->playlist->playlist_completed = true;
 2328|       |
 2329|  32.5k|        mpctx->playlist->current = new_entry;
 2330|  32.5k|        mpctx->playlist->current_was_replaced = false;
 2331|  32.5k|        mpctx->stop_play = new_entry ? PT_NEXT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2331:28): [True: 0, False: 32.5k]
  ------------------
 2332|       |
 2333|  32.5k|        if (!mpctx->playlist->current && mpctx->opts->player_idle_mode < 2)
  ------------------
  |  Branch (2333:13): [True: 32.5k, False: 0]
  |  Branch (2333:42): [True: 0, False: 32.5k]
  ------------------
 2334|      0|            break;
 2335|  32.5k|    }
 2336|       |
 2337|  32.5k|    cancel_open(mpctx);
 2338|       |
 2339|  32.5k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2339:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|}
mp_set_playlist_entry:
 2354|  32.5k|{
 2355|  32.5k|    mp_assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (2355:5): [True: 0, False: 32.5k]
  |  Branch (2355:5): [True: 32.5k, False: 0]
  ------------------
 2356|  32.5k|    mpctx->playlist->current = e;
 2357|  32.5k|    mpctx->playlist->current_was_replaced = false;
 2358|  32.5k|    mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
 2359|       |    // Make it pick up the new entry.
 2360|  32.5k|    if (mpctx->stop_play != PT_QUIT)
  ------------------
  |  Branch (2360:9): [True: 32.5k, False: 0]
  ------------------
 2361|  32.5k|        mpctx->stop_play = e ? PT_CURRENT_ENTRY : PT_STOP;
  ------------------
  |  Branch (2361:28): [True: 32.5k, False: 0]
  ------------------
 2362|  32.5k|    mp_wakeup_core(mpctx);
 2363|  32.5k|}
loadfile.c:track_in_current_edition:
  301|  79.1k|{
  302|  79.1k|    struct demuxer *demuxer = mpctx->demuxer;
  303|  79.1k|    if (!demuxer || !demuxer->edition_is_track_mapping || demuxer->num_editions <= 1)
  ------------------
  |  Branch (303:9): [True: 0, False: 79.1k]
  |  Branch (303:21): [True: 79.1k, False: 0]
  |  Branch (303:59): [True: 0, False: 0]
  ------------------
  304|  79.1k|        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|  39.5k|{
  245|  39.5k|    const char *tname = "?";
  246|  39.5k|    const char *selopt = "?";
  247|  39.5k|    const char *langopt = "?";
  248|  39.5k|    switch (t->type) {
  ------------------
  |  Branch (248:13): [True: 39.5k, False: 0]
  ------------------
  249|  32.6k|    case STREAM_VIDEO:
  ------------------
  |  Branch (249:5): [True: 32.6k, False: 6.89k]
  ------------------
  250|  32.6k|        tname = t->image ? "Image" : "Video"; selopt = "vid"; langopt = "vlang";
  ------------------
  |  Branch (250:17): [True: 0, False: 32.6k]
  ------------------
  251|  32.6k|        break;
  252|    201|    case STREAM_AUDIO:
  ------------------
  |  Branch (252:5): [True: 201, False: 39.3k]
  ------------------
  253|    201|        tname = "Audio"; selopt = "aid"; langopt = "alang";
  254|    201|        break;
  255|  6.69k|    case STREAM_SUB:
  ------------------
  |  Branch (255:5): [True: 6.69k, False: 32.8k]
  ------------------
  256|  6.69k|        tname = "Subs"; selopt = "sid"; langopt = "slang";
  257|  6.69k|        break;
  258|  39.5k|    }
  259|  39.5k|    char b[2048] = {0};
  260|       |
  261|  39.5k|    int max_lang_length = 0;
  262|  94.5k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (262:21): [True: 54.9k, False: 39.5k]
  ------------------
  263|  54.9k|        if (mpctx->tracks[n]->lang)
  ------------------
  |  Branch (263:13): [True: 0, False: 54.9k]
  ------------------
  264|      0|            max_lang_length = MPMAX(strlen(mpctx->tracks[n]->lang), max_lang_length);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  265|  54.9k|    }
  266|       |
  267|  39.5k|    if (indent)
  ------------------
  |  Branch (267:9): [True: 0, False: 39.5k]
  ------------------
  268|      0|        APPEND(b, " ");
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  269|  39.5k|    APPEND(b, "%s %-5s  --%s=%-2d", t->selected ? BLACK_CIRCLE : WHITE_CIRCLE,
  ------------------
  |  |  240|  79.0k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (240:54): [True: 39.1k, False: 340]
  |  |  ------------------
  ------------------
  270|  39.5k|           tname, selopt, t->user_tid);
  271|  39.5k|    if (t->lang) {
  ------------------
  |  Branch (271:9): [True: 0, False: 39.5k]
  ------------------
  272|      0|        APPEND(b, " --%s=%-*s ", langopt, max_lang_length, t->lang);
  ------------------
  |  |  240|      0|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  273|  39.5k|    } else if (max_lang_length) {
  ------------------
  |  Branch (273:16): [True: 0, False: 39.5k]
  ------------------
  274|      0|        FILL(b, (int) strlen(" --alang= ") + max_lang_length);
  ------------------
  |  |  241|      0|#define FILL(s, n) mp_snprintf_cat(s, sizeof(s), "%*s", n, "")
  ------------------
  275|      0|    }
  276|       |
  277|  39.5k|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|  39.5k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  39.5k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  278|  39.5k|    APPEND(b, " %s", mp_format_track_metadata(ctx, t, false));
  ------------------
  |  |  240|  39.5k|#define APPEND(s, ...) mp_snprintf_cat(s, sizeof(s), __VA_ARGS__)
  ------------------
  279|  39.5k|    talloc_free(ctx);
  ------------------
  |  |   47|  39.5k|#define talloc_free                     ta_free
  ------------------
  280|       |
  281|  39.5k|    MP_INFO(mpctx, "%s\n", b);
  ------------------
  |  |   91|  39.5k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  39.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  282|  39.5k|}
loadfile.c:add_stream_track:
  520|  72.0k|{
  521|  79.7k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (521:21): [True: 40.2k, False: 39.5k]
  ------------------
  522|  40.2k|        struct track *track = mpctx->tracks[i];
  523|  40.2k|        if (track->stream == stream)
  ------------------
  |  Branch (523:13): [True: 32.5k, False: 7.73k]
  ------------------
  524|  32.5k|            return track;
  525|  40.2k|    }
  526|       |
  527|  39.5k|    struct track *track = talloc_ptrtype(NULL, track);
  ------------------
  |  |   34|  39.5k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  39.5k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  39.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  528|  39.5k|    *track = (struct track) {
  529|  39.5k|        .type = stream->type,
  530|  39.5k|        .user_tid = find_new_tid(mpctx, stream->type),
  531|  39.5k|        .demuxer_id = stream->demuxer_id,
  532|  39.5k|        .ff_index = stream->ff_index,
  533|  39.5k|        .hls_bitrate = stream->hls_bitrate,
  534|  39.5k|        .title = stream->title,
  535|  39.5k|        .default_track = stream->default_track,
  536|  39.5k|        .forced_track = stream->forced_track,
  537|  39.5k|        .dependent_track = stream->dependent_track,
  538|  39.5k|        .visual_impaired_track = stream->visual_impaired_track,
  539|  39.5k|        .hearing_impaired_track = stream->hearing_impaired_track,
  540|  39.5k|        .original_track = stream->original_track,
  541|  39.5k|        .commentary_track = stream->commentary_track,
  542|  39.5k|        .image = stream->image,
  543|  39.5k|        .attached_picture = stream->attached_picture != NULL,
  544|  39.5k|        .lang = stream->lang,
  545|  39.5k|        .demuxer = demuxer,
  546|  39.5k|        .stream = stream,
  547|  39.5k|    };
  548|  39.5k|    MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
  ------------------
  |  |  105|  39.5k|    do {                                            \
  |  |  106|  39.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  39.5k|    do {                                            \
  |  |  |  |   97|  39.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  39.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  39.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  39.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.6k, False: 6.85k]
  |  |  |  |  ------------------
  |  |  |  |   99|  39.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.6k|    do {                                                        \
  |  |  |  |  |  |   89|  32.6k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.6k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.6k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.6k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.6k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.6k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.6k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.6k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  39.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 39.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  39.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  39.5k|        (idxvar)++;                                 \
  |  |  109|  39.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 39.5k]
  |  |  ------------------
  ------------------
  549|       |
  550|  39.5k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
  551|       |
  552|  39.5k|    return track;
  553|  72.0k|}
loadfile.c:find_new_tid:
  507|  39.5k|{
  508|  39.5k|    int new_id = 0;
  509|  47.2k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (509:21): [True: 7.73k, False: 39.5k]
  ------------------
  510|  7.73k|        struct track *track = mpctx->tracks[i];
  511|  7.73k|        if (track->type == t)
  ------------------
  |  Branch (511:13): [True: 331, False: 7.39k]
  ------------------
  512|    331|            new_id = MPMAX(new_id, track->user_tid);
  ------------------
  |  |   44|    331|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 331]
  |  |  ------------------
  ------------------
  513|  7.73k|    }
  514|  39.5k|    return new_id + 1;
  515|  39.5k|}
loadfile.c:process_langs:
  665|  97.5k|{
  666|  97.5k|    size_t nb = 0;
  667|  97.5k|    char **out = NULL;
  668|  97.5k|    for (int i = 0; in && in[i]; i++) {
  ------------------
  |  Branch (668:21): [True: 0, False: 97.5k]
  |  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|  97.5k|    return out;
  673|  97.5k|}
loadfile.c:add_os_langs:
  650|  32.5k|{
  651|  32.5k|    size_t nb = 0;
  652|  32.5k|    char **out = NULL;
  653|  32.5k|    char **autos = mp_get_user_langs();
  654|  32.5k|    for (int i = 0; autos && autos[i]; i++) {
  ------------------
  |  Branch (654:21): [True: 32.5k, False: 0]
  |  Branch (654:30): [True: 0, False: 32.5k]
  ------------------
  655|      0|        if (!append_lang(&nb, &out, autos[i]))
  ------------------
  |  Branch (655:13): [True: 0, False: 0]
  ------------------
  656|      0|            goto cleanup;
  657|      0|    }
  658|       |
  659|  32.5k|cleanup:
  660|  32.5k|    talloc_free(autos);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  661|  32.5k|    return out;
  662|  32.5k|}
loadfile.c:duplicate_track:
  630|  39.2k|{
  631|  39.2k|    for (int i = 0; i < order; i++) {
  ------------------
  |  Branch (631:21): [True: 0, False: 39.2k]
  ------------------
  632|      0|        if (mpctx->current_track[i][type] == track)
  ------------------
  |  Branch (632:13): [True: 0, False: 0]
  ------------------
  633|      0|            return true;
  634|      0|    }
  635|  39.2k|    return false;
  636|  39.2k|}
loadfile.c:compare_track:
  585|     13|{
  586|     13|    bool sub = t2->type == STREAM_SUB;
  587|     13|    bool ext1 = t1->is_external && !t1->no_default;
  ------------------
  |  Branch (587:17): [True: 13, False: 0]
  |  Branch (587:36): [True: 13, False: 0]
  ------------------
  588|     13|    bool ext2 = t2->is_external && !t2->no_default;
  ------------------
  |  Branch (588:17): [True: 13, False: 0]
  |  Branch (588:36): [True: 13, False: 0]
  ------------------
  589|     13|    if (ext1 != ext2 && t1->image == t2->image) {
  ------------------
  |  Branch (589:9): [True: 0, False: 13]
  |  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|     13|    if (t1->auto_loaded != t2->auto_loaded)
  ------------------
  |  Branch (595:9): [True: 0, False: 13]
  ------------------
  596|      0|        return !t1->auto_loaded;
  597|     13|    int l1 = mp_match_lang(langs, t1->lang), l2 = mp_match_lang(langs, t2->lang);
  598|     13|    if (!os_langs && l1 != l2)
  ------------------
  |  Branch (598:9): [True: 0, False: 13]
  |  Branch (598:22): [True: 0, False: 0]
  ------------------
  599|      0|        return l1 > l2;
  600|     13|    if (t1->forced_select != t2->forced_select)
  ------------------
  |  Branch (600:9): [True: 0, False: 13]
  ------------------
  601|      0|        return t1->forced_select;
  602|     13|    if (t1->default_track != t2->default_track)
  ------------------
  |  Branch (602:9): [True: 0, False: 13]
  ------------------
  603|      0|        return t1->default_track;
  604|     13|    if (sub && t1->forced_track != t2->forced_track)
  ------------------
  |  Branch (604:9): [True: 13, False: 0]
  |  Branch (604:16): [True: 0, False: 13]
  ------------------
  605|      0|        return !t1->forced_track;
  606|     13|    if (os_langs && l1 != l2)
  ------------------
  |  Branch (606:9): [True: 13, False: 0]
  |  Branch (606:21): [True: 0, False: 13]
  ------------------
  607|      0|        return l1 > l2;
  608|     13|    if (t1->attached_picture != t2->attached_picture)
  ------------------
  |  Branch (608:9): [True: 0, False: 13]
  ------------------
  609|      0|        return !t1->attached_picture;
  610|     13|    if (t1->image != t2->image)
  ------------------
  |  Branch (610:9): [True: 0, False: 13]
  ------------------
  611|      0|        return !t1->image;
  612|     13|    if (t1->dependent_track != t2->dependent_track)
  ------------------
  |  Branch (612:9): [True: 0, False: 13]
  ------------------
  613|      0|        return !t1->dependent_track;
  614|     13|    if (t1->stream && t2->stream && opts->hls_bitrate >= 0 &&
  ------------------
  |  Branch (614:9): [True: 13, False: 0]
  |  Branch (614:23): [True: 13, False: 0]
  |  Branch (614:37): [True: 13, False: 0]
  ------------------
  615|     13|        t1->stream->hls_bitrate != t2->stream->hls_bitrate)
  ------------------
  |  Branch (615:9): [True: 0, False: 13]
  ------------------
  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|     13|    return t1->user_tid <= t2->user_tid;
  626|     13|}
loadfile.c:track_layout_hash:
  758|     25|{
  759|     25|    char *h = talloc_strdup(NULL, "");
  ------------------
  |  |   50|     25|#define talloc_strdup                   ta_xstrdup
  ------------------
  760|    100|    for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
  ------------------
  |  Branch (760:24): [True: 75, False: 25]
  ------------------
  761|    402|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (761:25): [True: 327, False: 75]
  ------------------
  762|    327|            struct track *track = mpctx->tracks[n];
  763|    327|            if (track->type != type)
  ------------------
  |  Branch (763:17): [True: 218, False: 109]
  ------------------
  764|    218|                continue;
  765|    109|            h = talloc_asprintf_append_buffer(h, "%d-%d-%d-%d-%s\n", type,
  ------------------
  |  |   64|    109|#define talloc_asprintf_append_buffer   ta_talloc_asprintf_append_buffer
  ------------------
  766|    109|                    track->user_tid, track->default_track, track->is_external,
  767|    109|                    track->lang ? track->lang : "");
  ------------------
  |  Branch (767:21): [True: 0, False: 109]
  ------------------
  768|    109|        }
  769|     75|    }
  770|     25|    return h;
  771|     25|}
loadfile.c:enable_demux_thread:
  499|  57.5k|{
  500|  57.5k|    if (mpctx->opts->demuxer_thread && !demux->fully_read) {
  ------------------
  |  Branch (500:9): [True: 57.5k, False: 0]
  |  Branch (500:40): [True: 55.1k, False: 2.35k]
  ------------------
  501|  55.1k|        demux_set_wakeup_cb(demux, wakeup_demux, mpctx);
  502|  55.1k|        demux_start_thread(demux);
  503|  55.1k|    }
  504|  57.5k|}
loadfile.c:wakeup_demux:
   66|   116k|{
   67|   116k|    struct MPContext *mpctx = pctx;
   68|   116k|    mp_wakeup_core(mpctx);
   69|   116k|}
loadfile.c:start_open:
 1356|  32.5k|{
 1357|  32.5k|    cancel_open(mpctx);
 1358|       |
 1359|  32.5k|    mp_assert(!mpctx->open_active);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1359:5): [True: 32.5k, False: 0]
  ------------------
 1360|  32.5k|    mp_assert(!mpctx->open_cancel);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1360:5): [True: 32.5k, False: 0]
  ------------------
 1361|  32.5k|    mp_assert(!mpctx->open_res_demuxer);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1361:5): [True: 32.5k, False: 0]
  ------------------
 1362|  32.5k|    mp_assert(!atomic_load(&mpctx->open_done));
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1362:5): [True: 32.5k, False: 0]
  ------------------
 1363|       |
 1364|  32.5k|    mpctx->open_cancel = mp_cancel_new(NULL);
 1365|  32.5k|    mpctx->open_url = talloc_strdup(NULL, url);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1366|  32.5k|    mpctx->open_format = talloc_strdup(NULL, mpctx->opts->demuxer_name);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1367|  32.5k|    mpctx->open_url_flags = url_flags;
 1368|  32.5k|    mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread;
  ------------------
  |  Branch (1368:32): [True: 0, False: 32.5k]
  |  Branch (1368:48): [True: 0, False: 0]
  ------------------
 1369|  32.5k|    mpctx->demuxer_changed = false;
 1370|       |
 1371|  32.5k|    if (mp_thread_create(&mpctx->open_thread, open_demux_thread, mpctx)) {
  ------------------
  |  |  214|  32.5k|#define mp_thread_create(t, f, a) pthread_create(t, NULL, f, a)
  |  |  ------------------
  |  |  |  Branch (214:35): [True: 0, False: 32.5k]
  |  |  ------------------
  ------------------
 1372|      0|        cancel_open(mpctx);
 1373|      0|        return;
 1374|      0|    }
 1375|       |
 1376|  32.5k|    mpctx->open_active = true;
 1377|  32.5k|}
loadfile.c:open_demux_thread:
 1287|  32.5k|{
 1288|  32.5k|    struct MPContext *mpctx = ctx;
 1289|       |
 1290|  32.5k|    mp_thread_set_name("opener");
 1291|       |
 1292|  32.5k|    struct demuxer_params p = {
 1293|  32.5k|        .force_format = mpctx->open_format,
 1294|  32.5k|        .stream_flags = mpctx->open_url_flags,
 1295|  32.5k|        .stream_record = true,
 1296|  32.5k|        .is_top_level = true,
 1297|  32.5k|        .allow_playlist_create = mpctx->playlist->num_entries <= 1 &&
  ------------------
  |  Branch (1297:34): [True: 32.5k, False: 0]
  ------------------
 1298|  32.5k|                                 !mpctx->playlist->playlist_dir,
  ------------------
  |  Branch (1298:34): [True: 32.5k, False: 0]
  ------------------
 1299|  32.5k|    };
 1300|  32.5k|    struct demuxer *demux =
 1301|  32.5k|        demux_open_url(mpctx->open_url, &p, mpctx->open_cancel, mpctx->global);
 1302|  32.5k|    mpctx->open_res_demuxer = demux;
 1303|       |
 1304|  32.5k|    if (demux) {
  ------------------
  |  Branch (1304:9): [True: 32.5k, False: 0]
  ------------------
 1305|  32.5k|        MP_VERBOSE(mpctx, "Opening done: %s\n", mpctx->open_url);
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1306|       |
 1307|  32.5k|        if (mpctx->open_for_prefetch && !demux->fully_read) {
  ------------------
  |  Branch (1307:13): [True: 0, False: 32.5k]
  |  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|  32.5k|    } else {
 1319|      0|        MP_VERBOSE(mpctx, "Opening failed or was aborted: %s\n", mpctx->open_url);
  ------------------
  |  |   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__)
  |  |  ------------------
  ------------------
 1320|       |
 1321|      0|        if (p.demuxer_failed) {
  ------------------
  |  Branch (1321:13): [True: 0, False: 0]
  ------------------
 1322|      0|            mpctx->open_res_error = MPV_ERROR_UNKNOWN_FORMAT;
 1323|      0|        } else {
 1324|      0|            mpctx->open_res_error = MPV_ERROR_LOADING_FAILED;
 1325|      0|        }
 1326|      0|    }
 1327|       |
 1328|  32.5k|    atomic_store(&mpctx->open_done, true);
 1329|  32.5k|    mp_wakeup_core(mpctx);
 1330|       |    MP_THREAD_RETURN();
  ------------------
  |  |  212|  32.5k|#define MP_THREAD_RETURN() return NULL
  ------------------
 1331|  32.5k|}
loadfile.c:reinit_complex_filters:
 1533|  65.0k|{
 1534|  65.0k|    char *graph = mpctx->opts->lavfi_complex;
 1535|  65.0k|    bool have_graph = graph && graph[0] && !force_uninit;
  ------------------
  |  Branch (1535:23): [True: 0, False: 65.0k]
  |  Branch (1535:32): [True: 0, False: 0]
  |  Branch (1535:44): [True: 0, False: 0]
  ------------------
 1536|  65.0k|    if (have_graph && mpctx->lavfi &&
  ------------------
  |  Branch (1536:9): [True: 0, False: 65.0k]
  |  Branch (1536:23): [True: 0, False: 0]
  ------------------
 1537|      0|        strcmp(graph, mpctx->lavfi_graph) == 0 &&
  ------------------
  |  Branch (1537:9): [True: 0, False: 0]
  ------------------
 1538|      0|        !mp_filter_has_failed(mpctx->lavfi))
  ------------------
  |  Branch (1538:9): [True: 0, False: 0]
  ------------------
 1539|      0|        return 0;
 1540|  65.0k|    if (!mpctx->lavfi && !have_graph)
  ------------------
  |  Branch (1540:9): [True: 65.0k, False: 0]
  |  Branch (1540:26): [True: 65.0k, False: 0]
  ------------------
 1541|  65.0k|        return 0;
 1542|       |
 1543|       |    // Deassociate the old filter pads. We leave both sources (tracks) and
 1544|       |    // sinks (AO/VO) "dangling", connected to neither track or filter pad.
 1545|       |    // Later, we either reassociate them with new pads, or uninit them if
 1546|       |    // they are still dangling. This avoids too interruptive actions like
 1547|       |    // recreating the VO.
 1548|      0|    deassociate_complex_filters(mpctx);
 1549|       |
 1550|      0|    bool success = false;
 1551|      0|    if (!have_graph) {
  ------------------
  |  Branch (1551:9): [True: 0, False: 0]
  ------------------
 1552|      0|        success = true; // normal full removal of graph
 1553|      0|        goto done;
 1554|      0|    }
 1555|       |
 1556|      0|    struct mp_lavfi *l =
 1557|      0|        mp_lavfi_create_graph(mpctx->filter_root, 0, false, NULL, NULL, graph);
 1558|      0|    if (!l)
  ------------------
  |  Branch (1558:9): [True: 0, False: 0]
  ------------------
 1559|      0|        goto done;
 1560|      0|    mpctx->lavfi = l->f;
 1561|      0|    mpctx->lavfi_graph = talloc_strdup(NULL, graph);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
 1562|       |
 1563|      0|    mp_filter_set_error_handler(mpctx->lavfi, mpctx->filter_root);
 1564|       |
 1565|      0|    for (int n = 0; n < mpctx->lavfi->num_pins; n++)
  ------------------
  |  Branch (1565:21): [True: 0, False: 0]
  ------------------
 1566|      0|        mp_pin_disconnect(mpctx->lavfi->pins[n]);
 1567|       |
 1568|      0|    struct mp_pin *pad = mp_filter_get_named_pin(mpctx->lavfi, "vo");
 1569|      0|    if (pad && mp_pin_get_dir(pad) == MP_PIN_OUT) {
  ------------------
  |  Branch (1569:9): [True: 0, False: 0]
  |  Branch (1569:16): [True: 0, False: 0]
  ------------------
 1570|      0|        if (mpctx->vo_chain && mpctx->vo_chain->track)
  ------------------
  |  Branch (1570:13): [True: 0, False: 0]
  |  Branch (1570:32): [True: 0, False: 0]
  ------------------
 1571|      0|            kill_outputs(mpctx, mpctx->vo_chain->track);
 1572|      0|        if (!mpctx->vo_chain) {
  ------------------
  |  Branch (1572:13): [True: 0, False: 0]
  ------------------
 1573|      0|            reinit_video_chain_src(mpctx, NULL);
 1574|      0|            if (!mpctx->vo_chain)
  ------------------
  |  Branch (1574:17): [True: 0, False: 0]
  ------------------
 1575|      0|                goto done;
 1576|      0|        }
 1577|      0|        struct vo_chain *vo_c = mpctx->vo_chain;
 1578|      0|        mp_assert(!vo_c->track);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1578:9): [True: 0, False: 0]
  ------------------
 1579|      0|        vo_c->filter_src = pad;
 1580|      0|        mp_pin_connect(vo_c->filter->f->pins[0], vo_c->filter_src);
 1581|      0|    }
 1582|       |
 1583|      0|    pad = mp_filter_get_named_pin(mpctx->lavfi, "ao");
 1584|      0|    if (pad && mp_pin_get_dir(pad) == MP_PIN_OUT) {
  ------------------
  |  Branch (1584:9): [True: 0, False: 0]
  |  Branch (1584:16): [True: 0, False: 0]
  ------------------
 1585|      0|        if (mpctx->ao_chain && mpctx->ao_chain->track)
  ------------------
  |  Branch (1585:13): [True: 0, False: 0]
  |  Branch (1585:32): [True: 0, False: 0]
  ------------------
 1586|      0|            kill_outputs(mpctx, mpctx->ao_chain->track);
 1587|      0|        if (!mpctx->ao_chain) {
  ------------------
  |  Branch (1587:13): [True: 0, False: 0]
  ------------------
 1588|      0|            reinit_audio_chain_src(mpctx, NULL);
 1589|      0|            if (!mpctx->ao_chain)
  ------------------
  |  Branch (1589:17): [True: 0, False: 0]
  ------------------
 1590|      0|                goto done;
 1591|      0|        }
 1592|      0|        struct ao_chain *ao_c = mpctx->ao_chain;
 1593|      0|        mp_assert(!ao_c->track);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1593:9): [True: 0, False: 0]
  ------------------
 1594|      0|        ao_c->filter_src = pad;
 1595|      0|        mp_pin_connect(ao_c->filter->f->pins[0], ao_c->filter_src);
 1596|      0|    }
 1597|       |
 1598|      0|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1598:21): [True: 0, False: 0]
  ------------------
 1599|      0|        struct track *track = mpctx->tracks[n];
 1600|       |
 1601|      0|        char label[32];
 1602|      0|        char prefix;
 1603|      0|        switch (track->type) {
 1604|      0|        case STREAM_VIDEO: prefix = 'v'; break;
  ------------------
  |  Branch (1604:9): [True: 0, False: 0]
  ------------------
 1605|      0|        case STREAM_AUDIO: prefix = 'a'; break;
  ------------------
  |  Branch (1605:9): [True: 0, False: 0]
  ------------------
 1606|      0|        default: continue;
  ------------------
  |  Branch (1606:9): [True: 0, False: 0]
  ------------------
 1607|      0|        }
 1608|      0|        snprintf(label, sizeof(label), "%cid%d", prefix, track->user_tid);
 1609|       |
 1610|      0|        pad = mp_filter_get_named_pin(mpctx->lavfi, label);
 1611|      0|        if (!pad)
  ------------------
  |  Branch (1611:13): [True: 0, False: 0]
  ------------------
 1612|      0|            continue;
 1613|      0|        if (mp_pin_get_dir(pad) != MP_PIN_IN)
  ------------------
  |  Branch (1613:13): [True: 0, False: 0]
  ------------------
 1614|      0|            continue;
 1615|      0|        mp_assert(!mp_pin_is_connected(pad));
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1615:9): [True: 0, False: 0]
  ------------------
 1616|       |
 1617|      0|        mp_assert(!track->sink);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (1617:9): [True: 0, False: 0]
  ------------------
 1618|       |
 1619|      0|        kill_outputs(mpctx, track);
 1620|       |
 1621|      0|        track->sink = pad;
 1622|      0|        track->selected = true;
 1623|       |
 1624|      0|        if (!track->dec) {
  ------------------
  |  Branch (1624:13): [True: 0, False: 0]
  ------------------
 1625|      0|            bool ok = track->type == STREAM_VIDEO ? init_video_decoder(mpctx, track)
  ------------------
  |  Branch (1625:23): [True: 0, False: 0]
  ------------------
 1626|      0|                                                  : init_audio_decoder(mpctx, track);
 1627|      0|            if (!ok) {
  ------------------
  |  Branch (1627:17): [True: 0, False: 0]
  ------------------
 1628|      0|                error_on_track(mpctx, track);
 1629|      0|                goto done;
 1630|      0|            }
 1631|      0|        }
 1632|       |
 1633|      0|        mp_pin_connect(track->sink, track->dec->f->pins[0]);
 1634|      0|    }
 1635|       |
 1636|       |    // Don't allow unconnected pins. Libavfilter would make the data flow a
 1637|       |    // real pain anyway.
 1638|      0|    for (int n = 0; n < mpctx->lavfi->num_pins; n++) {
  ------------------
  |  Branch (1638:21): [True: 0, False: 0]
  ------------------
 1639|      0|        struct mp_pin *pin = mpctx->lavfi->pins[n];
 1640|      0|        if (!mp_pin_is_connected(pin)) {
  ------------------
  |  Branch (1640:13): [True: 0, False: 0]
  ------------------
 1641|      0|            MP_ERR(mpctx, "Pad %s is not connected to anything.\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1642|      0|                   mp_pin_get_name(pin));
 1643|      0|            goto done;
 1644|      0|        }
 1645|      0|    }
 1646|       |
 1647|      0|    success = true;
 1648|      0|done:
 1649|       |
 1650|      0|    if (!success)
  ------------------
  |  Branch (1650:9): [True: 0, False: 0]
  ------------------
 1651|      0|        deassociate_complex_filters(mpctx);
 1652|       |
 1653|      0|    cleanup_deassociated_complex_filters(mpctx);
 1654|       |
 1655|      0|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (1655:9): [True: 0, False: 0]
  ------------------
 1656|      0|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (1656:25): [True: 0, False: 0]
  ------------------
 1657|      0|            struct track *t = mpctx->tracks[n];
 1658|      0|            if (t->stream && t->stream->dependent_track && !t->selected)
  ------------------
  |  Branch (1658:17): [True: 0, False: 0]
  |  Branch (1658:30): [True: 0, False: 0]
  |  Branch (1658:60): [True: 0, False: 0]
  ------------------
 1659|      0|                continue;
 1660|      0|            reselect_demux_stream(mpctx, t, false);
 1661|      0|        }
 1662|      0|    }
 1663|       |
 1664|      0|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
 1665|       |
 1666|      0|    return success ? 1 : -1;
  ------------------
  |  Branch (1666:12): [True: 0, False: 0]
  ------------------
 1667|      0|}
loadfile.c:play_current_file:
 1820|  32.5k|{
 1821|  32.5k|    struct MPOpts *opts = mpctx->opts;
 1822|       |
 1823|  32.5k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1823:5): [True: 32.5k, False: 0]
  ------------------
 1824|  32.5k|    mpctx->stop_play = 0;
 1825|       |
 1826|  32.5k|    process_hooks(mpctx, "on_before_start_file");
 1827|  32.5k|    if (mpctx->stop_play || !mpctx->playlist->current)
  ------------------
  |  Branch (1827:9): [True: 0, False: 32.5k]
  |  Branch (1827:29): [True: 0, False: 32.5k]
  ------------------
 1828|      0|        return;
 1829|       |
 1830|  32.5k|    mpv_event_start_file start_event = {
 1831|  32.5k|        .playlist_entry_id = mpctx->playlist->current->id,
 1832|  32.5k|    };
 1833|  32.5k|    mpv_event_end_file end_event = {
 1834|  32.5k|        .playlist_entry_id = start_event.playlist_entry_id,
 1835|  32.5k|    };
 1836|       |
 1837|  32.5k|    mp_notify(mpctx, MPV_EVENT_START_FILE, &start_event);
 1838|       |
 1839|  32.5k|    mp_cancel_reset(mpctx->playback_abort);
 1840|       |
 1841|  32.5k|    mpctx->error_playing = MPV_ERROR_LOADING_FAILED;
 1842|  32.5k|    mpctx->filename = NULL;
 1843|  32.5k|    mpctx->shown_aframes = 0;
 1844|  32.5k|    mpctx->shown_vframes = 0;
 1845|  32.5k|    mpctx->last_chapter_seek = -2;
 1846|  32.5k|    mpctx->last_chapter_flag = false;
 1847|  32.5k|    mpctx->last_chapter = -2;
 1848|  32.5k|    mpctx->paused = false;
 1849|  32.5k|    mpctx->playing_msg_shown = false;
 1850|  32.5k|    mpctx->max_frames = -1;
 1851|  32.5k|    mpctx->video_speed = mpctx->audio_speed = opts->playback_speed;
 1852|  32.5k|    mpctx->speed_factor_a = mpctx->speed_factor_v = 1.0;
 1853|  32.5k|    mpctx->display_sync_error = 0.0;
 1854|  32.5k|    mpctx->display_sync_active = false;
 1855|       |    // let get_current_time() show 0 as start time (before playback_pts is set)
 1856|  32.5k|    mpctx->last_seek_pts = 0.0;
 1857|  32.5k|    mpctx->seek = (struct seek_params){ 0 };
 1858|  32.5k|    disc_nav_reset(mpctx);
 1859|  32.5k|    mpctx->filter_root = mp_filter_create_root(mpctx->global);
 1860|  32.5k|    mp_filter_graph_set_wakeup_cb(mpctx->filter_root, mp_wakeup_core_cb, mpctx);
 1861|  32.5k|    mp_filter_graph_set_max_run_time(mpctx->filter_root, 0.1);
 1862|       |
 1863|  32.5k|    reset_playback_state(mpctx);
 1864|       |
 1865|  32.5k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
 1866|  32.5k|    if (mpctx->playlist->num_entries > 3)
  ------------------
  |  Branch (1866:9): [True: 0, False: 32.5k]
  ------------------
 1867|      0|        goto terminate_playback;
 1868|  32.5k|#endif
 1869|       |
 1870|  32.5k|    mpctx->playing = mpctx->playlist->current;
 1871|  32.5k|    mp_assert(mpctx->playing);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1871:5): [True: 32.5k, False: 0]
  ------------------
 1872|  32.5k|    mp_assert(mpctx->playing->filename);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1872:5): [True: 32.5k, False: 0]
  ------------------
 1873|  32.5k|    mpctx->playing->reserved += 1;
 1874|       |
 1875|  32.5k|    mpctx->filename = talloc_strdup(NULL, mpctx->playing->filename);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1876|  32.5k|    mpctx->stream_open_filename = mpctx->filename;
 1877|       |
 1878|  32.5k|    mpctx->add_osd_seek_info &= OSD_SEEK_INFO_CURRENT_FILE;
 1879|       |
 1880|  32.5k|    if (opts->reset_options) {
  ------------------
  |  Branch (1880:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    mp_load_auto_profiles(mpctx);
 1894|       |
 1895|  32.5k|    bool watch_later = mp_load_playback_resume(mpctx, mpctx->filename);
 1896|       |
 1897|  32.5k|    load_per_file_options(mpctx->mconfig, mpctx->playing->params,
 1898|  32.5k|                          mpctx->playing->num_params);
 1899|       |
 1900|  32.5k|    mpctx->remaining_file_loops = mpctx->opts->loop_file;
 1901|  32.5k|    mp_notify_property(mpctx, "remaining-file-loops");
 1902|  32.5k|    mpctx->remaining_ab_loops = mpctx->opts->ab_loop_count;
 1903|  32.5k|    mp_notify_property(mpctx, "remaining-ab-loops");
 1904|       |
 1905|  32.5k|    mpctx->max_frames = opts->play_frames;
 1906|       |
 1907|  32.5k|    handle_force_window(mpctx, false);
 1908|       |
 1909|  32.5k|    if (mpctx->playlist->num_entries > 1 ||
  ------------------
  |  Branch (1909:9): [True: 0, False: 32.5k]
  ------------------
 1910|  32.5k|        mpctx->playing->playlist_path)
  ------------------
  |  Branch (1910:9): [True: 0, False: 32.5k]
  ------------------
 1911|  32.5k|        MP_INFO(mpctx, "Playing: %s\n", mpctx->filename);
  ------------------
  |  |   91|      0|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1912|       |
 1913|  32.5k|    mp_assert(mpctx->demuxer == NULL);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (1913:5): [True: 32.5k, False: 0]
  ------------------
 1914|       |
 1915|  32.5k|    process_hooks(mpctx, "on_load");
 1916|  32.5k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1916:9): [True: 0, False: 32.5k]
  ------------------
 1917|      0|        goto terminate_playback;
 1918|       |
 1919|  32.5k|    if (opts->stream_dump && opts->stream_dump[0]) {
  ------------------
  |  Branch (1919:9): [True: 0, False: 32.5k]
  |  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|  32.5k|    open_demux_reentrant(mpctx);
 1926|  32.5k|    if (!mpctx->stop_play && !mpctx->demuxer) {
  ------------------
  |  Branch (1926:9): [True: 32.5k, False: 0]
  |  Branch (1926:30): [True: 0, False: 32.5k]
  ------------------
 1927|      0|        process_hooks(mpctx, "on_load_fail");
 1928|      0|        if (strcmp(mpctx->stream_open_filename, mpctx->filename) != 0 &&
  ------------------
  |  Branch (1928:13): [True: 0, False: 0]
  ------------------
 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|      0|    }
 1935|  32.5k|    if (!mpctx->demuxer || mpctx->stop_play)
  ------------------
  |  Branch (1935:9): [True: 0, False: 32.5k]
  |  Branch (1935:28): [True: 0, False: 32.5k]
  ------------------
 1936|      0|        goto terminate_playback;
 1937|       |
 1938|  32.5k|    struct playlist *pl = mpctx->demuxer->playlist;
 1939|  32.5k|    if (pl) {
  ------------------
  |  Branch (1939:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    if (mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (1957:9): [True: 32.5k, False: 0]
  ------------------
 1958|  32.5k|        demux_set_ts_offset(mpctx->demuxer, -mpctx->demuxer->start_time);
 1959|  32.5k|    enable_demux_thread(mpctx, mpctx->demuxer);
 1960|       |
 1961|  32.5k|    add_demuxer_tracks(mpctx, mpctx->demuxer);
 1962|       |
 1963|  32.5k|    load_external_opts(mpctx);
 1964|  32.5k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1964:9): [True: 0, False: 32.5k]
  ------------------
 1965|      0|        goto terminate_playback;
 1966|       |
 1967|  32.5k|    check_previous_track_selection(mpctx);
 1968|       |
 1969|  32.5k|    process_hooks(mpctx, "on_preloaded");
 1970|  32.5k|    if (mpctx->stop_play)
  ------------------
  |  Branch (1970:9): [True: 0, False: 32.5k]
  ------------------
 1971|      0|        goto terminate_playback;
 1972|       |
 1973|  32.5k|    if (reinit_complex_filters(mpctx, false) < 0)
  ------------------
  |  Branch (1973:9): [True: 0, False: 32.5k]
  ------------------
 1974|      0|        goto terminate_playback;
 1975|       |
 1976|   130k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1976:21): [True: 97.5k, False: 32.5k]
  ------------------
 1977|   227k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1977:25): [True: 130k, False: 97.5k]
  ------------------
 1978|   130k|            struct track *sel = NULL;
 1979|   130k|            bool taken = (t == STREAM_VIDEO && mpctx->vo_chain) ||
  ------------------
  |  Branch (1979:27): [True: 32.5k, False: 97.5k]
  |  Branch (1979:48): [True: 0, False: 32.5k]
  ------------------
 1980|   130k|                         (t == STREAM_AUDIO && mpctx->ao_chain);
  ------------------
  |  Branch (1980:27): [True: 32.5k, False: 97.5k]
  |  Branch (1980:48): [True: 0, False: 32.5k]
  ------------------
 1981|   130k|            if (!taken && opts->stream_auto_sel)
  ------------------
  |  Branch (1981:17): [True: 130k, False: 0]
  |  Branch (1981:27): [True: 130k, False: 0]
  ------------------
 1982|   130k|                sel = select_default_track(mpctx, i, t);
 1983|   130k|            mpctx->current_track[i][t] = sel;
 1984|   130k|        }
 1985|  97.5k|    }
 1986|   130k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (1986:21): [True: 97.5k, False: 32.5k]
  ------------------
 1987|   227k|        for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (1987:25): [True: 130k, False: 97.5k]
  ------------------
 1988|       |            // One track can strictly feed at most 1 decoder
 1989|   130k|            struct track *track = mpctx->current_track[i][t];
 1990|   130k|            if (track) {
  ------------------
  |  Branch (1990:17): [True: 39.1k, False: 90.8k]
  ------------------
 1991|  39.1k|                if (track->type != STREAM_SUB &&
  ------------------
  |  Branch (1991:21): [True: 32.5k, False: 6.68k]
  ------------------
 1992|  32.5k|                    mpctx->encode_lavc_ctx &&
  ------------------
  |  Branch (1992:21): [True: 0, False: 32.5k]
  ------------------
 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|  39.1k|                } else if (track->selected) {
  ------------------
  |  Branch (2000:28): [True: 0, False: 39.1k]
  ------------------
 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|  39.1k|                } else {
 2006|  39.1k|                    track->selected = true;
 2007|  39.1k|                }
 2008|  39.1k|            }
 2009|       |
 2010|       |            // Revert selection of unselected tracks to default. This is needed
 2011|       |            // because track properties have inconsistent behavior.
 2012|   130k|            if (!track && opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (2012:17): [True: 90.8k, False: 39.1k]
  |  Branch (2012:27): [True: 0, False: 90.8k]
  ------------------
 2013|      0|                mark_track_selection(mpctx, i, t, -1); // default
 2014|   130k|        }
 2015|  97.5k|    }
 2016|       |
 2017|  32.5k|    process_hooks(mpctx, "on_loaded");
 2018|   130k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (2018:21): [True: 97.5k, False: 32.5k]
  ------------------
 2019|   216k|        for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (2019:25): [True: 118k, False: 97.5k]
  ------------------
 2020|   118k|            struct track *track = mpctx->tracks[n];
 2021|   118k|            if (track->type != t)
  ------------------
  |  Branch (2021:17): [True: 79.0k, False: 39.5k]
  ------------------
 2022|  79.0k|                continue;
 2023|       |            // Only reselect dependent tracks when explicitly selected by user
 2024|  39.5k|            if (track->stream && track->stream->dependent_track &&
  ------------------
  |  Branch (2024:17): [True: 39.5k, False: 0]
  |  Branch (2024:34): [True: 0, False: 39.5k]
  ------------------
 2025|      0|                !track->selected)
  ------------------
  |  Branch (2025:17): [True: 0, False: 0]
  ------------------
 2026|      0|                continue;
 2027|  39.5k|            reselect_demux_stream(mpctx, track, false);
 2028|  39.5k|        }
 2029|  97.5k|    }
 2030|       |
 2031|  32.5k|    update_demuxer_properties(mpctx);
 2032|       |
 2033|  32.5k|    update_playback_speed(mpctx);
 2034|       |
 2035|  32.5k|    reinit_video_chain(mpctx);
 2036|  32.5k|    reinit_audio_chain(mpctx);
 2037|  32.5k|    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|  32.5k|    update_vo_chain_el_pair(mpctx);
 2041|       |
 2042|  32.5k|    if (mpctx->encode_lavc_ctx) {
  ------------------
  |  Branch (2042:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    if (!mpctx->vo_chain && !mpctx->ao_chain && opts->stream_auto_sel) {
  ------------------
  |  Branch (2051:9): [True: 0, False: 32.5k]
  |  Branch (2051:29): [True: 0, False: 0]
  |  Branch (2051:49): [True: 0, False: 0]
  ------------------
 2052|      0|        MP_FATAL(mpctx, "No video or audio streams selected.\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__)
  |  |  ------------------
  ------------------
 2053|      0|        mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2054|      0|        goto terminate_playback;
 2055|      0|    }
 2056|       |
 2057|  32.5k|    if (mpctx->vo_chain && mpctx->vo_chain->is_coverart) {
  ------------------
  |  Branch (2057:9): [True: 32.5k, False: 0]
  |  Branch (2057:28): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (2062:9): [True: 0, False: 32.5k]
  ------------------
 2063|      0|        handle_force_window(mpctx, true);
 2064|       |
 2065|  32.5k|    MP_VERBOSE(mpctx, "Starting playback...\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2066|       |
 2067|  32.5k|    mpctx->playback_initialized = true;
 2068|  32.5k|    mpctx->playing->playlist_prev_attempt = false;
 2069|  32.5k|    mpctx->playlist->playlist_completed = false;
 2070|  32.5k|    mpctx->playlist->playlist_started = true;
 2071|  32.5k|    mp_notify(mpctx, MPV_EVENT_FILE_LOADED, NULL);
 2072|  32.5k|    update_screensaver_state(mpctx);
 2073|  32.5k|    clear_playlist_paths(mpctx);
 2074|       |
 2075|       |    // Clear out subs from the previous file if the video track is a still image.
 2076|  32.5k|    redraw_subs(mpctx);
 2077|       |
 2078|  32.5k|    if (watch_later)
  ------------------
  |  Branch (2078:9): [True: 0, False: 32.5k]
  ------------------
 2079|      0|        mp_delete_watch_later_conf(mpctx, mpctx->filename);
 2080|       |
 2081|  32.5k|    append_to_watch_history(mpctx);
 2082|       |
 2083|  32.5k|    if (mpctx->max_frames == 0) {
  ------------------
  |  Branch (2083:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    if (opts->demuxer_cache_wait) {
  ------------------
  |  Branch (2090:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    double play_start_pts = rel_time_to_abs(mpctx, opts->play_start);
 2105|       |
 2106|       |    // Backward playback -> start from end by default.
 2107|  32.5k|    if (play_start_pts == MP_NOPTS_VALUE && opts->play_dir < 0)
  ------------------
  |  |   39|  65.0k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2107:9): [True: 32.5k, False: 0]
  |  Branch (2107:45): [True: 0, False: 32.5k]
  ------------------
 2108|      0|        play_start_pts = get_start_time(mpctx, -1);
 2109|       |
 2110|  32.5k|    if (play_start_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  32.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (2110:9): [True: 0, False: 32.5k]
  ------------------
 2111|      0|        queue_seek(mpctx, MPSEEK_ABSOLUTE, play_start_pts, MPSEEK_DEFAULT, 0);
 2112|      0|        execute_queued_seek(mpctx);
 2113|      0|    }
 2114|       |
 2115|  32.5k|    update_internal_pause_state(mpctx);
 2116|       |
 2117|  32.5k|    mpctx->error_playing = 0;
 2118|  32.5k|    mpctx->in_playloop = true;
 2119|   941k|    while (!mpctx->stop_play)
  ------------------
  |  Branch (2119:12): [True: 909k, False: 32.5k]
  ------------------
 2120|   909k|        run_playloop(mpctx);
 2121|  32.5k|    mpctx->in_playloop = false;
 2122|       |
 2123|  32.5k|    MP_VERBOSE(mpctx, "EOF code: %d\n", mpctx->stop_play);
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2124|       |
 2125|  32.5k|terminate_playback:
 2126|       |
 2127|  32.5k|    if (!mpctx->stop_play)
  ------------------
  |  Branch (2127:9): [True: 0, False: 32.5k]
  ------------------
 2128|      0|        mpctx->stop_play = PT_ERROR;
 2129|       |
 2130|  32.5k|    if (mpctx->stop_play != AT_END_OF_FILE)
  ------------------
  |  Branch (2130:9): [True: 0, False: 32.5k]
  ------------------
 2131|      0|        clear_audio_output_buffers(mpctx);
 2132|       |
 2133|  32.5k|    update_core_idle_state(mpctx);
 2134|       |
 2135|  32.5k|    if (mpctx->step_frames) {
  ------------------
  |  Branch (2135:9): [True: 0, False: 32.5k]
  ------------------
 2136|      0|        opts->pause = true;
 2137|      0|        m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
 2138|      0|    }
 2139|       |
 2140|  32.5k|    process_hooks(mpctx, "on_unload");
 2141|       |
 2142|       |    // time to uninit all, except global stuff:
 2143|  32.5k|    reinit_complex_filters(mpctx, true);
 2144|  32.5k|    uninit_audio_chain(mpctx);
 2145|  32.5k|    uninit_video_chain(mpctx);
 2146|  32.5k|    uninit_sub_all(mpctx);
 2147|  32.5k|    if (!opts->gapless_audio && !mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (2147:9): [True: 0, False: 32.5k]
  |  Branch (2147:33): [True: 0, False: 0]
  ------------------
 2148|      0|        uninit_audio_out(mpctx);
 2149|       |
 2150|  32.5k|    mpctx->playback_initialized = false;
 2151|       |
 2152|  32.5k|    uninit_demuxer(mpctx);
 2153|       |
 2154|       |    // Possibly stop ongoing async commands.
 2155|  32.5k|    mp_abort_playback_async(mpctx);
 2156|       |
 2157|  32.5k|    struct playlist_entry *current = mpctx->playlist->current;
 2158|  32.5k|    bool reloading = mpctx->stop_play == PT_CURRENT_ENTRY &&
  ------------------
  |  Branch (2158:22): [True: 0, False: 32.5k]
  ------------------
 2159|      0|                     current && current->reloading;
  ------------------
  |  Branch (2159:22): [True: 0, False: 0]
  |  Branch (2159:33): [True: 0, False: 0]
  ------------------
 2160|  32.5k|    if (current)
  ------------------
  |  Branch (2160:9): [True: 32.5k, False: 0]
  ------------------
 2161|  32.5k|        current->reloading = false;
 2162|  32.5k|    if (!reloading)
  ------------------
  |  Branch (2162:9): [True: 32.5k, False: 0]
  ------------------
 2163|  32.5k|        m_config_restore_backups(mpctx->mconfig);
 2164|       |
 2165|  32.5k|    TA_FREEP(&mpctx->filter_root);
  ------------------
  |  |   81|  32.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  32.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
 2166|  32.5k|    talloc_free(mpctx->filtered_tags);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 2167|  32.5k|    mpctx->filtered_tags = NULL;
 2168|       |
 2169|  32.5k|    mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL);
 2170|       |
 2171|  32.5k|    if (encode_lavc_didfail(mpctx->encode_lavc_ctx))
  ------------------
  |  Branch (2171:9): [True: 0, False: 32.5k]
  ------------------
 2172|      0|        mpctx->stop_play = PT_ERROR;
 2173|       |
 2174|  32.5k|    if (mpctx->stop_play == PT_ERROR && !mpctx->error_playing)
  ------------------
  |  Branch (2174:9): [True: 0, False: 32.5k]
  |  Branch (2174:41): [True: 0, False: 0]
  ------------------
 2175|      0|        mpctx->error_playing = MPV_ERROR_GENERIC;
 2176|       |
 2177|  32.5k|    bool nothing_played = !mpctx->shown_aframes && !mpctx->shown_vframes &&
  ------------------
  |  Branch (2177:27): [True: 32.5k, False: 0]
  |  Branch (2177:52): [True: 0, False: 32.5k]
  ------------------
 2178|      0|                          mpctx->error_playing <= 0;
  ------------------
  |  Branch (2178:27): [True: 0, False: 0]
  ------------------
 2179|  32.5k|    bool playlist_prev_continue = false;
 2180|  32.5k|    switch (mpctx->stop_play) {
  ------------------
  |  Branch (2180:13): [True: 32.5k, False: 0]
  ------------------
 2181|      0|    case PT_ERROR:
  ------------------
  |  Branch (2181:5): [True: 0, False: 32.5k]
  ------------------
 2182|  32.5k|    case AT_END_OF_FILE:
  ------------------
  |  Branch (2182:5): [True: 32.5k, False: 0]
  ------------------
 2183|  32.5k|    {
 2184|  32.5k|        if (mpctx->error_playing == 0 && nothing_played)
  ------------------
  |  Branch (2184:13): [True: 32.5k, False: 0]
  |  Branch (2184:42): [True: 0, False: 32.5k]
  ------------------
 2185|      0|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
 2186|  32.5k|        if (mpctx->error_playing < 0) {
  ------------------
  |  Branch (2186:13): [True: 0, False: 32.5k]
  ------------------
 2187|      0|            end_event.error = mpctx->error_playing;
 2188|      0|            end_event.reason = MPV_END_FILE_REASON_ERROR;
 2189|  32.5k|        } else if (mpctx->error_playing == 2) {
  ------------------
  |  Branch (2189:20): [True: 0, False: 32.5k]
  ------------------
 2190|      0|            end_event.reason = MPV_END_FILE_REASON_REDIRECT;
 2191|  32.5k|        } else {
 2192|  32.5k|            end_event.reason = MPV_END_FILE_REASON_EOF;
 2193|  32.5k|        }
 2194|  32.5k|        if (mpctx->playing) {
  ------------------
  |  Branch (2194:13): [True: 32.5k, False: 0]
  ------------------
 2195|  32.5k|            mpctx->playing->init_failed = nothing_played;
 2196|  32.5k|            playlist_prev_continue = mpctx->playing->playlist_prev_attempt &&
  ------------------
  |  Branch (2196:38): [True: 0, False: 32.5k]
  ------------------
 2197|      0|                                     nothing_played;
  ------------------
  |  Branch (2197:38): [True: 0, False: 0]
  ------------------
 2198|  32.5k|            mpctx->playing->playlist_prev_attempt = false;
 2199|  32.5k|        }
 2200|  32.5k|        break;
 2201|      0|    }
 2202|       |    // Note that error_playing is meaningless in these cases.
 2203|      0|    case PT_NEXT_ENTRY:
  ------------------
  |  Branch (2203:5): [True: 0, False: 32.5k]
  ------------------
 2204|      0|    case PT_CURRENT_ENTRY:
  ------------------
  |  Branch (2204:5): [True: 0, False: 32.5k]
  ------------------
 2205|      0|    case PT_STOP:           end_event.reason = MPV_END_FILE_REASON_STOP; break;
  ------------------
  |  Branch (2205:5): [True: 0, False: 32.5k]
  ------------------
 2206|      0|    case PT_QUIT:           end_event.reason = MPV_END_FILE_REASON_QUIT; break;
  ------------------
  |  Branch (2206:5): [True: 0, False: 32.5k]
  ------------------
 2207|  32.5k|    };
 2208|  32.5k|    mp_notify(mpctx, MPV_EVENT_END_FILE, &end_event);
 2209|       |
 2210|  32.5k|    MP_VERBOSE(mpctx, "finished playback, %s (reason %d)\n",
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 2211|  32.5k|               mpv_error_string(end_event.error), end_event.reason);
 2212|  32.5k|    if (end_event.error == MPV_ERROR_UNKNOWN_FORMAT)
  ------------------
  |  Branch (2212:9): [True: 0, False: 32.5k]
  ------------------
 2213|  32.5k|        MP_ERR(mpctx, "Failed to recognize file 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__)
  |  |  ------------------
  ------------------
 2214|       |
 2215|  32.5k|    if (mpctx->playing)
  ------------------
  |  Branch (2215:9): [True: 32.5k, False: 0]
  ------------------
 2216|  32.5k|        playlist_entry_unref(mpctx->playing);
 2217|  32.5k|    mpctx->playing = NULL;
 2218|  32.5k|    talloc_free(mpctx->filename);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 2219|  32.5k|    mpctx->filename = NULL;
 2220|  32.5k|    mpctx->stream_open_filename = NULL;
 2221|       |
 2222|  32.5k|    if (end_event.error < 0 && nothing_played) {
  ------------------
  |  Branch (2222:9): [True: 0, False: 32.5k]
  |  Branch (2222:32): [True: 0, False: 0]
  ------------------
 2223|      0|        mpctx->files_broken++;
 2224|  32.5k|    } else if (end_event.error < 0) {
  ------------------
  |  Branch (2224:16): [True: 0, False: 32.5k]
  ------------------
 2225|      0|        mpctx->files_errored++;
 2226|  32.5k|    } else {
 2227|  32.5k|        mpctx->files_played++;
 2228|  32.5k|    }
 2229|       |
 2230|  32.5k|    mp_assert(mpctx->stop_play);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (2230:5): [True: 32.5k, False: 0]
  ------------------
 2231|       |
 2232|  32.5k|    process_hooks(mpctx, "on_after_end_file");
 2233|       |
 2234|  32.5k|    if (playlist_prev_continue) {
  ------------------
  |  Branch (2234:9): [True: 0, False: 32.5k]
  ------------------
 2235|      0|        struct playlist_entry *e = mp_next_file(mpctx, -1, false, true);
 2236|      0|        if (e) {
  ------------------
  |  Branch (2236:13): [True: 0, False: 0]
  ------------------
 2237|      0|            mp_set_playlist_entry(mpctx, e);
 2238|      0|            play_current_file(mpctx);
 2239|      0|        }
 2240|      0|    }
 2241|  32.5k|}
loadfile.c:process_hooks:
 1225|   195k|{
 1226|   195k|    mp_hook_start(mpctx, name);
 1227|       |
 1228|   195k|    while (!mp_hook_test_completion(mpctx, name)) {
  ------------------
  |  Branch (1228:12): [True: 0, False: 195k]
  ------------------
 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|   195k|}
loadfile.c:load_per_file_options:
 1279|  32.5k|{
 1280|  32.5k|    for (int n = 0; n < params_count; n++) {
  ------------------
  |  Branch (1280:21): [True: 0, False: 32.5k]
  ------------------
 1281|      0|        m_config_set_option_cli(conf, params[n].name, params[n].value,
 1282|      0|                                M_SETOPT_BACKUP);
 1283|      0|    }
 1284|  32.5k|}
loadfile.c:open_demux_reentrant:
 1380|  32.5k|{
 1381|  32.5k|    char *url = mpctx->stream_open_filename;
 1382|       |
 1383|  32.5k|    if (mpctx->open_active) {
  ------------------
  |  Branch (1383:9): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1410:9): [True: 32.5k, False: 0]
  ------------------
 1411|  32.5k|        start_open(mpctx, url, mpctx->playing->stream_flags, false);
 1412|       |
 1413|       |    // If thread failed to start, cancel the playback
 1414|  32.5k|    if (!mpctx->open_active)
  ------------------
  |  Branch (1414:9): [True: 0, False: 32.5k]
  ------------------
 1415|      0|        goto cancel;
 1416|       |
 1417|       |    // User abort should cancel the opener now.
 1418|  32.5k|    mp_cancel_set_parent(mpctx->open_cancel, mpctx->playback_abort);
 1419|       |
 1420|  97.5k|    while (!atomic_load(&mpctx->open_done)) {
  ------------------
  |  Branch (1420:12): [True: 65.0k, False: 32.5k]
  ------------------
 1421|  65.0k|        mp_idle(mpctx);
 1422|       |
 1423|  65.0k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1423:13): [True: 0, False: 65.0k]
  ------------------
 1424|      0|            mp_abort_playback_async(mpctx);
 1425|  65.0k|    }
 1426|       |
 1427|  32.5k|    if (mpctx->open_res_demuxer) {
  ------------------
  |  Branch (1427:9): [True: 32.5k, False: 0]
  ------------------
 1428|  32.5k|        mpctx->demuxer = mpctx->open_res_demuxer;
 1429|  32.5k|        mpctx->open_res_demuxer = NULL;
 1430|  32.5k|        mp_cancel_set_parent(mpctx->demuxer->cancel, mpctx->playback_abort);
 1431|  32.5k|    } else {
 1432|      0|        mpctx->error_playing = mpctx->open_res_error;
 1433|      0|    }
 1434|       |
 1435|  32.5k|cancel:
 1436|  32.5k|    cancel_open(mpctx); // cleanup
 1437|  32.5k|}
loadfile.c:load_external_opts:
 1715|  32.5k|{
 1716|  32.5k|    struct mp_waiter wait = MP_WAITER_INITIALIZER;
  ------------------
  |  |   19|  32.5k|#define MP_WAITER_INITIALIZER { \
  |  |   20|  32.5k|    .lock = MP_STATIC_MUTEX_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  109|  32.5k|#define MP_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
  |  |  ------------------
  |  |   21|  32.5k|    .wakeup = MP_STATIC_COND_INITIALIZER, \
  |  |  ------------------
  |  |  |  |  108|  32.5k|#define MP_STATIC_COND_INITIALIZER { .cond = PTHREAD_COND_INITIALIZER, .clk_id = CLOCK_REALTIME }
  |  |  ------------------
  |  |   22|  32.5k|    }
  ------------------
 1717|       |
 1718|  32.5k|    void *a[] = {mpctx, &wait};
 1719|  32.5k|    if (!mp_thread_pool_queue(mpctx->thread_pool, load_external_opts_thread, a)) {
  ------------------
  |  Branch (1719:9): [True: 0, False: 32.5k]
  ------------------
 1720|      0|        mpctx->stop_play = PT_ERROR;
 1721|      0|        return;
 1722|      0|    }
 1723|       |
 1724|  65.0k|    while (!mp_waiter_poll(&wait)) {
  ------------------
  |  Branch (1724:12): [True: 32.5k, False: 32.5k]
  ------------------
 1725|  32.5k|        mp_idle(mpctx);
 1726|       |
 1727|  32.5k|        if (mpctx->stop_play)
  ------------------
  |  Branch (1727:13): [True: 0, False: 32.5k]
  ------------------
 1728|      0|            mp_abort_playback_async(mpctx);
 1729|  32.5k|    }
 1730|       |
 1731|  32.5k|    mp_waiter_wait(&wait);
 1732|  32.5k|}
loadfile.c:load_external_opts_thread:
 1695|  32.5k|{
 1696|  32.5k|    void **a = p;
 1697|  32.5k|    struct MPContext *mpctx = a[0];
 1698|  32.5k|    struct mp_waiter *waiter = a[1];
 1699|       |
 1700|  32.5k|    mp_core_lock(mpctx);
 1701|       |
 1702|  32.5k|    load_chapters(mpctx);
 1703|  32.5k|    open_external_files(mpctx, mpctx->opts->audio_files, STREAM_AUDIO);
 1704|  32.5k|    open_external_files(mpctx, mpctx->opts->sub_name, STREAM_SUB);
 1705|  32.5k|    open_external_files(mpctx, mpctx->opts->coverart_files, STREAM_VIDEO);
 1706|  32.5k|    open_external_files(mpctx, mpctx->opts->external_files, STREAM_TYPE_COUNT);
 1707|  32.5k|    autoload_external_files(mpctx, mpctx->playback_abort);
 1708|       |
 1709|  32.5k|    mp_waiter_wakeup(waiter, 0);
 1710|  32.5k|    mp_wakeup_core(mpctx);
 1711|  32.5k|    mp_core_unlock(mpctx);
 1712|  32.5k|}
loadfile.c:load_chapters:
 1240|  32.5k|{
 1241|  32.5k|    struct demuxer *src = mpctx->demuxer;
 1242|  32.5k|    bool free_src = false;
 1243|  32.5k|    char *chapter_file = mpctx->opts->chapter_file;
 1244|  32.5k|    if (chapter_file && chapter_file[0]) {
  ------------------
  |  Branch (1244:9): [True: 0, False: 32.5k]
  |  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|  32.5k|    if (src && !mpctx->chapters) {
  ------------------
  |  Branch (1263:9): [True: 32.5k, False: 0]
  |  Branch (1263:16): [True: 32.5k, False: 0]
  ------------------
 1264|  32.5k|        talloc_free(mpctx->chapters);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
 1265|  32.5k|        mpctx->num_chapters = src->num_chapters;
 1266|  32.5k|        mpctx->chapters = demux_copy_chapter_data(src->chapters, src->num_chapters);
 1267|  32.5k|        if (mpctx->opts->rebase_start_time) {
  ------------------
  |  Branch (1267:13): [True: 32.5k, False: 0]
  ------------------
 1268|  32.5k|            for (int n = 0; n < mpctx->num_chapters; n++)
  ------------------
  |  Branch (1268:29): [True: 0, False: 32.5k]
  ------------------
 1269|      0|                mpctx->chapters[n].pts -= src->start_time;
 1270|  32.5k|        }
 1271|  32.5k|    }
 1272|  32.5k|    if (free_src)
  ------------------
  |  Branch (1272:9): [True: 0, False: 32.5k]
  ------------------
 1273|      0|        demux_cancel_and_free(src);
 1274|  32.5k|}
loadfile.c:open_external_files:
 1090|   130k|{
 1091|       |    // Need a copy, because the option value could be mutated during iteration.
 1092|   130k|    void *tmp = talloc_new(NULL);
  ------------------
  |  |   40|   130k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|   130k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1093|   130k|    files = mp_dup_str_array(tmp, files);
 1094|       |
 1095|   162k|    for (int n = 0; files && files[n]; n++)
  ------------------
  |  Branch (1095:21): [True: 65.0k, False: 97.5k]
  |  Branch (1095:30): [True: 32.5k, False: 32.5k]
  ------------------
 1096|       |        // when given filter is set to video, we are loading up cover art
 1097|  32.5k|        mp_add_external_file(mpctx, files[n], filter, mpctx->playback_abort,
 1098|  32.5k|                             filter == STREAM_VIDEO ? TRACK_ATTACHED_PICTURE : 0);
  ------------------
  |  Branch (1098:30): [True: 0, False: 32.5k]
  ------------------
 1099|       |
 1100|   130k|    talloc_free(tmp);
  ------------------
  |  |   47|   130k|#define talloc_free                     ta_free
  ------------------
 1101|   130k|}
loadfile.c:check_previous_track_selection:
  776|  32.5k|{
  777|  32.5k|    struct MPOpts *opts = mpctx->opts;
  778|       |
  779|  32.5k|    if (!mpctx->track_layout_hash)
  ------------------
  |  Branch (779:9): [True: 32.5k, False: 0]
  ------------------
  780|  32.5k|        return;
  781|       |
  782|      0|    char *h = track_layout_hash(mpctx);
  783|      0|    if (strcmp(h, mpctx->track_layout_hash) != 0) {
  ------------------
  |  Branch (783:9): [True: 0, False: 0]
  ------------------
  784|       |        // Reset selection, but only if they're not "auto" or "off". The
  785|       |        // defaults are -1 (default selection), or -2 (off) for secondary tracks.
  786|      0|        for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (786:25): [True: 0, False: 0]
  ------------------
  787|      0|            for (int i = 0; i < num_ptracks[t]; i++) {
  ------------------
  |  Branch (787:29): [True: 0, False: 0]
  ------------------
  788|      0|                if (opts->stream_id[i][t] >= 0)
  ------------------
  |  Branch (788:21): [True: 0, False: 0]
  ------------------
  789|      0|                    mark_track_selection(mpctx, i, t, i == 0 ? -1 : -2);
  ------------------
  |  Branch (789:55): [True: 0, False: 0]
  ------------------
  790|      0|            }
  791|      0|        }
  792|      0|        talloc_free(mpctx->track_layout_hash);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  793|      0|        mpctx->track_layout_hash = NULL;
  794|      0|    }
  795|      0|    talloc_free(h);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  796|      0|}
loadfile.c:clear_playlist_paths:
 1452|  32.5k|{
 1453|       |    TA_FREEP(&mpctx->playlist_paths);
  ------------------
  |  |   81|  32.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  32.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
 1454|  32.5k|    mpctx->playlist_paths_len = 0;
 1455|  32.5k|}
loadfile.c:append_to_watch_history:
 1735|  32.5k|{
 1736|  32.5k|    if (!mpctx->opts->save_watch_history)
  ------------------
  |  Branch (1736:9): [True: 32.5k, False: 0]
  ------------------
 1737|  32.5k|        return;
 1738|       |
 1739|      0|    void *ctx = talloc_new(NULL);
  ------------------
  |  |   40|      0|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|      0|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
 1740|      0|    char *history_path = mp_get_user_path(ctx, mpctx->global,
 1741|      0|                                          mpctx->opts->watch_history_path);
 1742|      0|    char *history_path_dir = bstrto0(ctx, mp_dirname(history_path));
 1743|      0|    mp_mkdirp(history_path_dir);
 1744|       |
 1745|      0|    FILE *history_file = fopen(history_path, "ab");
  ------------------
  |  |   84|      0|#define fopen(...) mp_fopen(__VA_ARGS__)
  ------------------
 1746|      0|    if (!history_file) {
  ------------------
  |  Branch (1746:9): [True: 0, False: 0]
  ------------------
 1747|      0|        MP_ERR(mpctx, "Failed to open history file: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1748|      0|               mp_strerror(errno));
 1749|      0|        goto done;
 1750|      0|    }
 1751|       |
 1752|      0|    char *title = (char *)mp_find_non_filename_media_title(mpctx);
 1753|       |
 1754|      0|    mpv_node_list *list = talloc_zero(ctx, mpv_node_list);
  ------------------
  |  |   27|      0|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|      0|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1755|      0|    mpv_node node = {
 1756|      0|        .format = MPV_FORMAT_NODE_MAP,
 1757|      0|        .u.list = list,
 1758|      0|    };
 1759|      0|    list->num = title ? 3 : 2;
  ------------------
  |  Branch (1759:17): [True: 0, False: 0]
  ------------------
 1760|      0|    list->keys = talloc_array(ctx, char*, list->num);
  ------------------
  |  |   29|      0|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      0|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1761|      0|    list->values = talloc_array(ctx, mpv_node, list->num);
  ------------------
  |  |   29|      0|#define talloc_array                    ta_xnew_array
  |  |  ------------------
  |  |  |  |  135|      0|#define ta_xnew_array(...)              ta_oom_g(ta_new_array(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|      0|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1762|      0|    list->keys[0] = "time";
 1763|      0|    list->values[0] = (struct mpv_node) {
 1764|      0|        .format = MPV_FORMAT_INT64,
 1765|      0|        .u.int64 = time(NULL),
 1766|      0|    };
 1767|      0|    list->keys[1] = "path";
 1768|      0|    list->values[1] = (struct mpv_node) {
 1769|      0|        .format = MPV_FORMAT_STRING,
 1770|      0|        .u.string = mpctx->filename,
 1771|      0|    };
 1772|      0|    if (title) {
  ------------------
  |  Branch (1772:9): [True: 0, False: 0]
  ------------------
 1773|      0|        list->keys[2] = "title";
 1774|      0|        list->values[2] = (struct mpv_node) {
 1775|      0|            .format = MPV_FORMAT_STRING,
 1776|      0|            .u.string = title,
 1777|      0|        };
 1778|      0|    }
 1779|       |
 1780|      0|    bstr dst = {0};
 1781|      0|    json_append(&dst, &node, -1);
 1782|      0|    talloc_steal(ctx, dst.start);
  ------------------
  |  |   38|      0|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|      0|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
 1783|      0|    if (!dst.len) {
  ------------------
  |  Branch (1783:9): [True: 0, False: 0]
  ------------------
 1784|      0|        MP_ERR(mpctx, "Failed to serialize history entry\n");
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1785|      0|        goto done;
 1786|      0|    }
 1787|      0|    bstr_xappend0(ctx, &dst, "\n");
 1788|       |
 1789|      0|    int seek = fseek(history_file, 0, SEEK_END);
 1790|      0|    off_t history_size = ftell(history_file);
 1791|      0|    if (seek != 0 || history_size == -1) {
  ------------------
  |  Branch (1791:9): [True: 0, False: 0]
  |  Branch (1791:22): [True: 0, False: 0]
  ------------------
 1792|      0|        MP_ERR(mpctx, "Failed to get history file size: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1793|      0|               mp_strerror(errno));
 1794|      0|        goto done;
 1795|      0|    }
 1796|       |
 1797|      0|    bool failed = fwrite(dst.start, dst.len, 1, history_file) != 1 ||
  ------------------
  |  Branch (1797:19): [True: 0, False: 0]
  ------------------
 1798|      0|                  fflush(history_file) != 0;
  ------------------
  |  Branch (1798:19): [True: 0, False: 0]
  ------------------
 1799|       |
 1800|      0|    if (failed) {
  ------------------
  |  Branch (1800:9): [True: 0, False: 0]
  ------------------
 1801|      0|        MP_ERR(mpctx, "Failed to write to history file: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1802|      0|               mp_strerror(errno));
 1803|       |
 1804|      0|        int fd = fileno(history_file);
 1805|      0|        if (fd == -1 || ftruncate(fd, history_size) == -1)
  ------------------
  |  Branch (1805:13): [True: 0, False: 0]
  |  Branch (1805:25): [True: 0, False: 0]
  ------------------
 1806|      0|            MP_ERR(mpctx, "Failed to roll-back history file: %s\n",
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1807|      0|                   mp_strerror(errno));
 1808|      0|    }
 1809|       |
 1810|      0|done:
 1811|      0|    if (history_file != NULL && fclose(history_file) != 0)
  ------------------
  |  Branch (1811:9): [True: 0, False: 0]
  |  Branch (1811:33): [True: 0, False: 0]
  ------------------
 1812|      0|        MP_ERR(mpctx, "Failed to close history file: %s\n", mp_strerror(errno));
  ------------------
  |  |   89|      0|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1813|       |
 1814|      0|    talloc_free(ctx);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1815|      0|}
loadfile.c:uninit_demuxer:
  193|  32.5k|{
  194|   130k|    for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
  ------------------
  |  Branch (194:21): [True: 97.5k, False: 32.5k]
  ------------------
  195|   227k|        for (int r = 0; r < num_ptracks[t]; r++)
  ------------------
  |  Branch (195:25): [True: 130k, False: 97.5k]
  ------------------
  196|   130k|            mpctx->current_track[r][t] = NULL;
  197|  97.5k|    }
  198|       |
  199|  32.5k|    talloc_free(mpctx->chapters);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  200|  32.5k|    mpctx->chapters = NULL;
  201|  32.5k|    mpctx->num_chapters = 0;
  202|       |
  203|  32.5k|    mp_abort_cache_dumping(mpctx);
  204|       |
  205|  32.5k|    struct demuxer **demuxers = NULL;
  206|  32.5k|    int num_demuxers = 0;
  207|       |
  208|  32.5k|    if (mpctx->demuxer)
  ------------------
  |  Branch (208:9): [True: 32.5k, False: 0]
  ------------------
  209|  32.5k|        MP_TARRAY_APPEND(NULL, demuxers, num_demuxers, mpctx->demuxer);
  ------------------
  |  |  105|  32.5k|    do {                                            \
  |  |  106|  32.5k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  32.5k|    do {                                            \
  |  |  |  |   97|  32.5k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  32.5k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  32.5k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  32.5k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  32.5k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  32.5k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 32.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  32.5k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  32.5k|        (idxvar)++;                                 \
  |  |  109|  32.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  210|  32.5k|    mpctx->demuxer = NULL;
  211|       |
  212|  72.0k|    for (int i = 0; i < mpctx->num_tracks; i++) {
  ------------------
  |  Branch (212:21): [True: 39.5k, False: 32.5k]
  ------------------
  213|  39.5k|        struct track *track = mpctx->tracks[i];
  214|       |
  215|  39.5k|        mp_assert(!track->dec && !track->d_sub);
  ------------------
  |  |   41|  39.5k|#define mp_assert assert
  ------------------
  |  Branch (215:9): [True: 39.5k, False: 0]
  |  Branch (215:9): [True: 39.5k, False: 0]
  ------------------
  216|  39.5k|        mp_assert(!track->vo_c && !track->ao_c);
  ------------------
  |  |   41|  39.5k|#define mp_assert assert
  ------------------
  |  Branch (216:9): [True: 39.5k, False: 0]
  |  Branch (216:9): [True: 39.5k, False: 0]
  ------------------
  217|  39.5k|        mp_assert(!track->sink);
  ------------------
  |  |   41|  39.5k|#define mp_assert assert
  ------------------
  |  Branch (217:9): [True: 39.5k, False: 0]
  ------------------
  218|       |
  219|       |        // Demuxers can be added in any order (if they appear mid-stream), and
  220|       |        // we can't know which tracks uses which, so here's some O(n^2) trash.
  221|  46.5k|        for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (221:25): [True: 39.8k, False: 6.68k]
  ------------------
  222|  39.8k|            if (demuxers[n] == track->demuxer) {
  ------------------
  |  Branch (222:17): [True: 32.8k, False: 7.02k]
  ------------------
  223|  32.8k|                track->demuxer = NULL;
  224|  32.8k|                break;
  225|  32.8k|            }
  226|  39.8k|        }
  227|  39.5k|        if (track->demuxer)
  ------------------
  |  Branch (227:13): [True: 6.68k, False: 32.8k]
  ------------------
  228|  6.68k|            MP_TARRAY_APPEND(NULL, demuxers, num_demuxers, track->demuxer);
  ------------------
  |  |  105|  6.68k|    do {                                            \
  |  |  106|  6.68k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  6.68k|    do {                                            \
  |  |  |  |   97|  6.68k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  6.68k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  6.68k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  6.68k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 6.68k]
  |  |  |  |  ------------------
  |  |  |  |   99|  6.68k|            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|  6.68k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 6.68k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  6.68k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  6.68k|        (idxvar)++;                                 \
  |  |  109|  6.68k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 6.68k]
  |  |  ------------------
  ------------------
  229|       |
  230|  39.5k|        talloc_free(track);
  ------------------
  |  |   47|  39.5k|#define talloc_free                     ta_free
  ------------------
  231|  39.5k|    }
  232|  32.5k|    mpctx->num_tracks = 0;
  233|       |
  234|  32.5k|    kill_demuxers_reentrant(mpctx, demuxers, num_demuxers);
  235|  32.5k|    talloc_free(demuxers);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  236|       |
  237|  32.5k|    disc_nav_reset(mpctx);
  238|  32.5k|}
loadfile.c:kill_demuxers_reentrant:
  135|  32.5k|{
  136|  32.5k|    struct demux_free_async_state **items = NULL;
  137|  32.5k|    int num_items = 0;
  138|       |
  139|  71.7k|    for (int n = 0; n < num_demuxers; n++) {
  ------------------
  |  Branch (139:21): [True: 39.1k, False: 32.5k]
  ------------------
  140|  39.1k|        struct demuxer *d = demuxers[n];
  141|       |
  142|  39.1k|        if (!demux_cancel_test(d)) {
  ------------------
  |  Branch (142:13): [True: 39.1k, False: 0]
  ------------------
  143|       |            // Make sure it is set if it wasn't yet.
  144|  39.1k|            demux_set_wakeup_cb(d, wakeup_demux, mpctx);
  145|       |
  146|  39.1k|            struct demux_free_async_state *item = demux_free_async(d);
  147|  39.1k|            if (item) {
  ------------------
  |  Branch (147:17): [True: 36.8k, False: 2.34k]
  ------------------
  148|  36.8k|                MP_TARRAY_APPEND(NULL, items, num_items, item);
  ------------------
  |  |  105|  36.8k|    do {                                            \
  |  |  106|  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: 32.5k, False: 4.33k]
  |  |  |  |  ------------------
  |  |  |  |   99|  36.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  36.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 36.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  36.8k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  36.8k|        (idxvar)++;                                 \
  |  |  109|  36.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 36.8k]
  |  |  ------------------
  ------------------
  149|  36.8k|                d = NULL;
  150|  36.8k|            }
  151|  39.1k|        }
  152|       |
  153|  39.1k|        demux_cancel_and_free(d);
  154|  39.1k|    }
  155|       |
  156|  32.5k|    if (!num_items)
  ------------------
  |  Branch (156:9): [True: 0, False: 32.5k]
  ------------------
  157|      0|        return;
  158|       |
  159|  32.5k|    MP_DBG(mpctx, "Terminating demuxers...\n");
  ------------------
  |  |   93|  32.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  160|       |
  161|  32.5k|    double end = mp_time_sec() + mpctx->opts->demux_termination_timeout;
  162|  32.5k|    bool force = false;
  163|   138k|    while (num_items) {
  ------------------
  |  Branch (163:12): [True: 105k, False: 32.5k]
  ------------------
  164|   105k|        double wait = end - mp_time_sec();
  165|       |
  166|   187k|        for (int n = 0; n < num_items; n++) {
  ------------------
  |  Branch (166:25): [True: 118k, False: 69.0k]
  ------------------
  167|   118k|            struct demux_free_async_state *item = items[n];
  168|   118k|            if (demux_free_async_finish(item)) {
  ------------------
  |  Branch (168:17): [True: 36.8k, False: 81.9k]
  ------------------
  169|  36.8k|                items[n] = items[num_items - 1];
  170|  36.8k|                num_items -= 1;
  171|  36.8k|                n--;
  172|  36.8k|                goto repeat;
  173|  81.9k|            } else if (wait < 0) {
  ------------------
  |  Branch (173:24): [True: 0, False: 81.9k]
  ------------------
  174|      0|                demux_free_async_force(item);
  175|      0|                if (!force)
  ------------------
  |  Branch (175:21): [True: 0, False: 0]
  ------------------
  176|      0|                    MP_VERBOSE(mpctx, "Forcefully terminating demuxers...\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  177|      0|                force = true;
  178|      0|            }
  179|   118k|        }
  180|       |
  181|  69.0k|        if (wait >= 0)
  ------------------
  |  Branch (181:13): [True: 69.0k, False: 0]
  ------------------
  182|  69.0k|            mp_set_timeout(mpctx, wait);
  183|  69.0k|        mp_idle(mpctx);
  184|   105k|    repeat:;
  185|   105k|    }
  186|       |
  187|  32.5k|    talloc_free(items);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  188|       |
  189|  32.5k|    MP_DBG(mpctx, "Done terminating demuxers.\n");
  ------------------
  |  |   93|  32.5k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  190|  32.5k|}
loadfile.c:cancel_open:
 1334|  97.5k|{
 1335|  97.5k|    if (mpctx->open_cancel)
  ------------------
  |  Branch (1335:9): [True: 32.5k, False: 65.0k]
  ------------------
 1336|  32.5k|        mp_cancel_trigger(mpctx->open_cancel);
 1337|       |
 1338|  97.5k|    if (mpctx->open_active)
  ------------------
  |  Branch (1338:9): [True: 32.5k, False: 65.0k]
  ------------------
 1339|  32.5k|        mp_thread_join(mpctx->open_thread);
  ------------------
  |  |  215|  32.5k|#define mp_thread_join(t)         pthread_join(t, NULL)
  ------------------
 1340|  97.5k|    mpctx->open_active = false;
 1341|       |
 1342|  97.5k|    if (mpctx->open_res_demuxer)
  ------------------
  |  Branch (1342:9): [True: 0, False: 97.5k]
  ------------------
 1343|      0|        demux_cancel_and_free(mpctx->open_res_demuxer);
 1344|  97.5k|    mpctx->open_res_demuxer = NULL;
 1345|       |
 1346|  97.5k|    TA_FREEP(&mpctx->open_cancel);
  ------------------
  |  |   81|  97.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  97.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 97.5k]
  |  |  ------------------
  ------------------
 1347|  97.5k|    TA_FREEP(&mpctx->open_url);
  ------------------
  |  |   81|  97.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  97.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 97.5k]
  |  |  ------------------
  ------------------
 1348|  97.5k|    TA_FREEP(&mpctx->open_format);
  ------------------
  |  |   81|  97.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  97.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 97.5k]
  |  |  ------------------
  ------------------
 1349|       |
 1350|       |    atomic_store(&mpctx->open_done, false);
 1351|  97.5k|}

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

rel_time_to_abs:
   55|  1.65M|{
   56|  1.65M|    double length = get_time_length(mpctx);
   57|       |    // Relative times are an offset to the start of the file.
   58|  1.65M|    double start = 0;
   59|  1.65M|    if (mpctx->demuxer && !mpctx->opts->rebase_start_time)
  ------------------
  |  Branch (59:9): [True: 1.65M, False: 0]
  |  Branch (59:27): [True: 0, False: 1.65M]
  ------------------
   60|      0|        start = mpctx->demuxer->start_time;
   61|       |
   62|  1.65M|    switch (t.type) {
  ------------------
  |  Branch (62:13): [True: 0, False: 1.65M]
  ------------------
   63|      0|    case REL_TIME_ABSOLUTE:
  ------------------
  |  Branch (63:5): [True: 0, False: 1.65M]
  ------------------
   64|      0|        return t.pos;
   65|      0|    case REL_TIME_RELATIVE:
  ------------------
  |  Branch (65:5): [True: 0, False: 1.65M]
  ------------------
   66|      0|        if (t.pos >= 0) {
  ------------------
  |  Branch (66:13): [True: 0, False: 0]
  ------------------
   67|      0|            return start + t.pos;
   68|      0|        } else {
   69|      0|            if (length >= 0)
  ------------------
  |  Branch (69:17): [True: 0, False: 0]
  ------------------
   70|      0|                return start + MPMAX(length + t.pos, 0.0);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   71|      0|        }
   72|      0|        break;
   73|      0|    case REL_TIME_PERCENT:
  ------------------
  |  Branch (73:5): [True: 0, False: 1.65M]
  ------------------
   74|      0|        if (length >= 0)
  ------------------
  |  Branch (74:13): [True: 0, False: 0]
  ------------------
   75|      0|            return start + length * (t.pos / 100.0);
   76|      0|        break;
   77|      0|    case REL_TIME_CHAPTER:
  ------------------
  |  Branch (77:5): [True: 0, False: 1.65M]
  ------------------
   78|      0|        return chapter_start_time(mpctx, t.pos); // already absolute time
   79|  1.65M|    }
   80|       |
   81|  1.65M|    return MP_NOPTS_VALUE;
  ------------------
  |  |   39|  1.65M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
   82|  1.65M|}
get_play_end_pts:
  100|   812k|{
  101|   812k|    double end = get_play_end_pts_setting(mpctx);
  102|   812k|    double ab[2];
  103|   812k|    if (mpctx->ab_loop_clip && get_ab_loop_times(mpctx, ab)) {
  ------------------
  |  Branch (103:9): [True: 32.5k, False: 780k]
  |  Branch (103:32): [True: 0, False: 32.5k]
  ------------------
  104|      0|        if (end == MP_NOPTS_VALUE || end > ab[1])
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (104:13): [True: 0, False: 0]
  |  Branch (104:38): [True: 0, False: 0]
  ------------------
  105|      0|            end = ab[1];
  106|      0|    }
  107|   812k|    return end;
  108|   812k|}
get_ab_loop_times:
  125|  97.5k|{
  126|  97.5k|    struct MPOpts *opts = mpctx->opts;
  127|  97.5k|    int dir = mpctx->play_dir;
  128|       |
  129|  97.5k|    t[0] = opts->ab_loop[0];
  130|  97.5k|    t[1] = opts->ab_loop[1];
  131|       |
  132|  97.5k|    if (!mpctx->remaining_ab_loops)
  ------------------
  |  Branch (132:9): [True: 0, False: 97.5k]
  ------------------
  133|      0|        return false;
  134|       |
  135|  97.5k|    if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|   195k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (t[0] == MP_NOPTS_VALUE || t[1] == MP_NOPTS_VALUE || t[0] == t[1])
  ------------------
  |  |   39|  97.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (135:9): [True: 97.5k, False: 0]
  |  Branch (135:35): [True: 0, False: 0]
  |  Branch (135:61): [True: 0, False: 0]
  ------------------
  136|  97.5k|        return false;
  137|       |
  138|      0|    if (t[0] * dir > t[1] * dir)
  ------------------
  |  Branch (138:9): [True: 0, False: 0]
  ------------------
  139|      0|        MPSWAP(double, t[0], t[1]);
  ------------------
  |  |   48|      0|    do { type SWAP_tmp = b; b = a; a = SWAP_tmp; } while (0)
  |  |  ------------------
  |  |  |  Branch (48:59): [Folded, False: 0]
  |  |  ------------------
  ------------------
  140|       |
  141|       |    return true;
  142|  97.5k|}
get_track_seek_offset:
  145|  39.5k|{
  146|  39.5k|    struct MPOpts *opts = mpctx->opts;
  147|  39.5k|    if (track->selected) {
  ------------------
  |  Branch (147:9): [True: 39.2k, False: 365]
  ------------------
  148|  39.2k|        if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (148:13): [True: 0, False: 39.2k]
  ------------------
  149|      0|            return -opts->audio_delay;
  150|  39.2k|        if (track->type == STREAM_SUB)
  ------------------
  |  Branch (150:13): [True: 6.68k, False: 32.5k]
  ------------------
  151|  6.68k|        {
  152|  6.68k|            for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (152:29): [True: 6.68k, False: 0]
  ------------------
  153|  6.68k|                if (mpctx->current_track[n][STREAM_SUB] == track)
  ------------------
  |  Branch (153:21): [True: 6.68k, False: 0]
  ------------------
  154|  6.68k|                    return -opts->subs_shared->sub_delay[n];
  155|  6.68k|            }
  156|  6.68k|        }
  157|  39.2k|    }
  158|  32.8k|    return 0;
  159|  39.5k|}
update_content_type:
  178|  32.5k|{
  179|  32.5k|    enum mp_content_type content_type;
  180|  32.5k|    if (!track || !track->vo_c) {
  ------------------
  |  Branch (180:9): [True: 0, False: 32.5k]
  |  Branch (180:19): [True: 0, False: 32.5k]
  ------------------
  181|      0|        content_type = MP_CONTENT_NONE;
  182|  32.5k|    } else if (track->image) {
  ------------------
  |  Branch (182:16): [True: 0, False: 32.5k]
  ------------------
  183|      0|        content_type = MP_CONTENT_IMAGE;
  184|  32.5k|    } else {
  185|  32.5k|        content_type = MP_CONTENT_VIDEO;
  186|  32.5k|    }
  187|  32.5k|    if (mpctx->video_out)
  ------------------
  |  Branch (187:9): [True: 32.5k, False: 0]
  ------------------
  188|  32.5k|        vo_control(mpctx->video_out, VOCTRL_CONTENT_TYPE, &content_type);
  189|  32.5k|}
update_vo_playback_state:
  192|   845k|{
  193|   845k|    if (mpctx->video_out && mpctx->video_out->config_ok) {
  ------------------
  |  Branch (193:9): [True: 812k, False: 32.5k]
  |  Branch (193:29): [True: 812k, False: 2]
  ------------------
  194|   812k|        struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
  195|   812k|        double pos = get_current_pos_ratio(mpctx, false);
  196|   812k|        struct voctrl_playback_state newstate = {
  197|   812k|            .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0,
  ------------------
  |  Branch (197:33): [True: 812k, False: 0]
  |  Branch (197:70): [True: 792k, False: 20.3k]
  ------------------
  198|   812k|            .playing = mpctx->playing,
  199|   812k|            .paused = mpctx->paused,
  200|   812k|            .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0,
  ------------------
  |  Branch (200:25): [True: 747k, False: 65.1k]
  ------------------
  201|   812k|        };
  202|       |
  203|   812k|        bool state_changed = oldstate.taskbar_progress != newstate.taskbar_progress ||
  ------------------
  |  Branch (203:30): [True: 32.5k, False: 780k]
  ------------------
  204|   780k|                             oldstate.playing != newstate.playing ||
  ------------------
  |  Branch (204:30): [True: 20.3k, False: 760k]
  ------------------
  205|   760k|                             oldstate.paused != newstate.paused;
  ------------------
  |  Branch (205:30): [True: 4, False: 760k]
  ------------------
  206|   812k|        if (state_changed || oldstate.position != newstate.position) {
  ------------------
  |  Branch (206:13): [True: 52.8k, False: 760k]
  |  Branch (206:30): [True: 747k, False: 12.2k]
  ------------------
  207|       |            // Don't update progress bar if it was and still is hidden
  208|   800k|            if ((oldstate.playing && oldstate.taskbar_progress) ||
  ------------------
  |  Branch (208:18): [True: 768k, False: 32.5k]
  |  Branch (208:38): [True: 747k, False: 20.3k]
  ------------------
  209|  52.8k|                (newstate.playing && newstate.taskbar_progress))
  ------------------
  |  Branch (209:18): [True: 52.8k, False: 0]
  |  Branch (209:38): [True: 32.5k, False: 20.3k]
  ------------------
  210|   780k|            {
  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|   780k|                int64_t now = mp_time_ns();
  218|   780k|                int64_t elapsed = now - mpctx->vo_playback_state_time;
  219|   780k|                if (!state_changed && elapsed < MP_TIME_MS_TO_NS(1000))
  ------------------
  |  |   72|   747k|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  |  Branch (219:21): [True: 747k, False: 32.5k]
  |  Branch (219:39): [True: 747k, False: 0]
  ------------------
  220|   747k|                    return;
  221|  32.5k|                mpctx->vo_playback_state_time = now;
  222|  32.5k|                vo_control_async(mpctx->video_out,
  223|  32.5k|                                 VOCTRL_UPDATE_PLAYBACK_STATE, &newstate);
  224|  32.5k|            }
  225|  52.8k|            mpctx->vo_playback_state = newstate;
  226|  52.8k|        }
  227|   812k|    } else {
  228|  32.5k|        mpctx->vo_playback_state = (struct voctrl_playback_state){ 0 };
  229|  32.5k|    }
  230|   845k|}
update_window_title:
  233|   878k|{
  234|   878k|    if (!mpctx->video_out && !mpctx->ao) {
  ------------------
  |  Branch (234:9): [True: 32.5k, False: 845k]
  |  Branch (234:30): [True: 32.5k, False: 0]
  ------------------
  235|  32.5k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  236|  32.5k|        mpctx->last_window_title = NULL;
  237|  32.5k|        return;
  238|  32.5k|    }
  239|   845k|    char *title = mp_property_expand_string(mpctx, mpctx->opts->wintitle);
  240|   845k|    if (!mpctx->last_window_title || force ||
  ------------------
  |  Branch (240:9): [True: 32.5k, False: 812k]
  |  Branch (240:38): [True: 0, False: 812k]
  ------------------
  241|   812k|        strcmp(title, mpctx->last_window_title) != 0)
  ------------------
  |  Branch (241:9): [True: 0, False: 812k]
  ------------------
  242|  32.5k|    {
  243|  32.5k|        talloc_free(mpctx->last_window_title);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  244|  32.5k|        mpctx->last_window_title = talloc_steal(mpctx, title);
  ------------------
  |  |   38|  32.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  32.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  245|       |
  246|  32.5k|        if (mpctx->video_out)
  ------------------
  |  Branch (246:13): [True: 32.5k, False: 0]
  ------------------
  247|  32.5k|            vo_control(mpctx->video_out, VOCTRL_UPDATE_WINDOW_TITLE, title);
  248|       |
  249|  32.5k|        if (mpctx->ao) {
  ------------------
  |  Branch (249:13): [True: 0, False: 32.5k]
  ------------------
  250|      0|            ao_control(mpctx->ao, AOCONTROL_UPDATE_STREAM_TITLE, title);
  251|      0|        }
  252|   812k|    } else {
  253|   812k|        talloc_free(title);
  ------------------
  |  |   47|   812k|#define talloc_free                     ta_free
  ------------------
  254|   812k|    }
  255|   845k|}
error_on_track:
  258|  32.5k|{
  259|  32.5k|    if (!track || !track->selected)
  ------------------
  |  Branch (259:9): [True: 32.5k, False: 25]
  |  Branch (259:19): [True: 0, False: 25]
  ------------------
  260|  32.5k|        return;
  261|     25|    int order = -1;
  262|     25|    for (int t = 0; t < num_ptracks[track->type]; t++) {
  ------------------
  |  Branch (262:21): [True: 25, False: 0]
  ------------------
  263|     25|        if (mpctx->current_track[t][track->type] == track) {
  ------------------
  |  Branch (263:13): [True: 25, False: 0]
  ------------------
  264|     25|            order = t;
  265|     25|            break;
  266|     25|        }
  267|     25|    }
  268|       |    // Select the next best track, if the current one failed to initialize.
  269|     25|    if (order >= 0 && track->dec_failed && mpctx->opts->stream_auto_sel &&
  ------------------
  |  Branch (269:9): [True: 25, False: 0]
  |  Branch (269:23): [True: 25, False: 0]
  |  Branch (269:44): [True: 25, False: 0]
  ------------------
  270|     25|        mpctx->opts->stream_id[order][track->type] == -1)
  ------------------
  |  Branch (270:9): [True: 25, False: 0]
  ------------------
  271|     25|    {
  272|     25|        struct track *next = select_default_track(mpctx, order, track->type);
  273|     25|        if (next) {
  ------------------
  |  Branch (273:13): [True: 5, False: 20]
  ------------------
  274|      5|            MP_WARN(mpctx, "Falling back to %s track %d.\n",
  ------------------
  |  |   90|      5|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      5|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  275|      5|                    stream_type_name(track->type), next->user_tid);
  276|      5|            mp_switch_track_n(mpctx, order, track->type, next, 0);
  277|      5|            if (mpctx->current_track[order][track->type] != track)
  ------------------
  |  Branch (277:17): [True: 5, False: 0]
  ------------------
  278|      5|                return;
  279|      5|        }
  280|     25|    }
  281|     20|    mp_deselect_track(mpctx, track);
  282|     20|    if (track->type == STREAM_AUDIO)
  ------------------
  |  Branch (282:9): [True: 0, False: 20]
  ------------------
  283|     20|        MP_INFO(mpctx, "Audio: no audio\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__)
  |  |  ------------------
  ------------------
  284|     20|    if (track->type == STREAM_VIDEO)
  ------------------
  |  Branch (284:9): [True: 0, False: 20]
  ------------------
  285|     20|        MP_INFO(mpctx, "Video: no video\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__)
  |  |  ------------------
  ------------------
  286|     20|    if (mpctx->opts->stop_playback_on_init_failure ||
  ------------------
  |  Branch (286:9): [True: 0, False: 20]
  ------------------
  287|     20|        (!mpctx->current_track[0][STREAM_AUDIO] &&
  ------------------
  |  Branch (287:10): [True: 20, False: 0]
  ------------------
  288|     20|         !mpctx->current_track[0][STREAM_VIDEO]))
  ------------------
  |  Branch (288:10): [True: 0, False: 20]
  ------------------
  289|      0|    {
  290|      0|        if (!mpctx->stop_play)
  ------------------
  |  Branch (290:13): [True: 0, False: 0]
  ------------------
  291|      0|            mpctx->stop_play = PT_ERROR;
  292|      0|        if (mpctx->error_playing >= 0)
  ------------------
  |  Branch (292:13): [True: 0, False: 0]
  ------------------
  293|      0|            mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;
  294|      0|    }
  295|     20|    mp_wakeup_core(mpctx);
  296|     20|}
mp_status_str:
  375|   974k|{
  376|   974k|    switch (st) {
  377|  93.5k|    case STATUS_SYNCING:    return "syncing";
  ------------------
  |  Branch (377:5): [True: 93.5k, False: 880k]
  ------------------
  378|      0|    case STATUS_READY:      return "ready";
  ------------------
  |  Branch (378:5): [True: 0, False: 974k]
  ------------------
  379|   848k|    case STATUS_PLAYING:    return "playing";
  ------------------
  |  Branch (379:5): [True: 848k, False: 126k]
  ------------------
  380|    121|    case STATUS_DRAINING:   return "draining";
  ------------------
  |  Branch (380:5): [True: 121, False: 974k]
  ------------------
  381|  32.5k|    case STATUS_EOF:        return "eof";
  ------------------
  |  Branch (381:5): [True: 32.5k, False: 941k]
  ------------------
  382|      0|    default:                return "bug";
  ------------------
  |  Branch (382:5): [True: 0, False: 974k]
  ------------------
  383|   974k|    }
  384|   974k|}
mp_format_track_metadata:
  392|  39.5k|{
  393|  39.5k|    struct sh_stream *s = t->stream;
  394|  39.5k|    bstr dst = {0};
  395|       |
  396|  39.5k|    if (t->title)
  ------------------
  |  Branch (396:9): [True: 7.02k, False: 32.5k]
  ------------------
  397|  7.02k|        bstr_xappend_asprintf(ctx, &dst, "'%s' ", t->title);
  398|       |
  399|  39.5k|    bstr_xappend0(ctx, &dst, "(");
  400|       |
  401|  39.5k|    if (add_lang && t->lang)
  ------------------
  |  Branch (401:9): [True: 0, False: 39.5k]
  |  Branch (401:21): [True: 0, False: 0]
  ------------------
  402|      0|        bstr_xappend_asprintf(ctx, &dst, "%s ", t->lang);
  403|       |
  404|  39.5k|    if (s) {
  ------------------
  |  Branch (404:9): [True: 39.5k, False: 0]
  ------------------
  405|  39.5k|        demux_append_codec_desc(ctx, &dst, s, NULL);
  406|  39.5k|    } else {
  407|      0|        bstr_xappend0(ctx, &dst, "<unknown>");
  408|      0|    }
  409|  39.5k|    bstr_xappend0(ctx, &dst, ")");
  410|       |
  411|  39.5k|    bool first = true;
  412|  39.5k|    if (t->default_track)
  ------------------
  |  Branch (412:9): [True: 0, False: 39.5k]
  ------------------
  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|  39.5k|    if (t->forced_track)
  ------------------
  |  Branch (414:9): [True: 0, False: 39.5k]
  ------------------
  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|  39.5k|    if (t->dependent_track)
  ------------------
  |  Branch (416:9): [True: 0, False: 39.5k]
  ------------------
  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|  39.5k|    if (t->visual_impaired_track)
  ------------------
  |  Branch (418:9): [True: 0, False: 39.5k]
  ------------------
  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|  39.5k|    if (t->hearing_impaired_track)
  ------------------
  |  Branch (420:9): [True: 0, False: 39.5k]
  ------------------
  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|  39.5k|    if (t->original_track)
  ------------------
  |  Branch (422:9): [True: 0, False: 39.5k]
  ------------------
  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|  39.5k|    if (t->commentary_track)
  ------------------
  |  Branch (424:9): [True: 0, False: 39.5k]
  ------------------
  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|  39.5k|    if (t->is_external)
  ------------------
  |  Branch (426:9): [True: 7.02k, False: 32.5k]
  ------------------
  427|  7.02k|        ADD_FLAG(ctx, dst, "external", first);
  ------------------
  |  |  386|  7.02k|#define ADD_FLAG(ctx, dst, flag, first) do {                           \
  |  |  387|  7.02k|    bstr_xappend_asprintf(ctx, &dst, " %s%s", first ? "[" : "", flag); \
  |  |  ------------------
  |  |  |  Branch (387:47): [True: 7.02k, False: 0]
  |  |  ------------------
  |  |  388|  7.02k|    first = false;                                                     \
  |  |  389|  7.02k|} while(0)
  |  |  ------------------
  |  |  |  Branch (389:9): [Folded, False: 7.02k]
  |  |  ------------------
  ------------------
  428|  39.5k|    if (!first)
  ------------------
  |  Branch (428:9): [True: 7.02k, False: 32.5k]
  ------------------
  429|  7.02k|        bstr_xappend0(ctx, &dst, "]");
  430|       |
  431|  39.5k|    return bstrto0(ctx, dst);
  432|  39.5k|}
mp_find_non_filename_media_title:
  435|  8.48M|{
  436|  8.48M|    const char *name = mpctx->opts->media_title;
  437|  8.48M|    if (name && name[0])
  ------------------
  |  Branch (437:9): [True: 0, False: 8.48M]
  |  Branch (437:17): [True: 0, False: 0]
  ------------------
  438|      0|        return name;
  439|  8.48M|    if (mpctx->demuxer) {
  ------------------
  |  Branch (439:9): [True: 8.48M, False: 0]
  ------------------
  440|  8.48M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "service_name");
  441|  8.48M|        if (name && name[0])
  ------------------
  |  Branch (441:13): [True: 0, False: 8.48M]
  |  Branch (441:21): [True: 0, False: 0]
  ------------------
  442|      0|            return name;
  443|  8.48M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "title");
  444|  8.48M|        if (name && name[0])
  ------------------
  |  Branch (444:13): [True: 0, False: 8.48M]
  |  Branch (444:21): [True: 0, False: 0]
  ------------------
  445|      0|            return name;
  446|  8.48M|        name = mp_tags_get_str(mpctx->demuxer->metadata, "icy-title");
  447|  8.48M|        if (name && name[0])
  ------------------
  |  Branch (447:13): [True: 0, False: 8.48M]
  |  Branch (447:21): [True: 0, False: 0]
  ------------------
  448|      0|            return name;
  449|  8.48M|    }
  450|  8.48M|    if (mpctx->playing && mpctx->playing->title)
  ------------------
  |  Branch (450:9): [True: 8.48M, False: 0]
  |  Branch (450:27): [True: 0, False: 8.48M]
  ------------------
  451|      0|        return mpctx->playing->title;
  452|  8.48M|    if (mpctx->demuxer && mpctx->demuxer->server_filename)
  ------------------
  |  Branch (452:9): [True: 8.48M, False: 0]
  |  Branch (452:27): [True: 0, False: 8.48M]
  ------------------
  453|      0|        return mpctx->demuxer->server_filename;
  454|  8.48M|    return NULL;
  455|  8.48M|}
misc.c:get_play_end_pts_setting:
   85|   812k|{
   86|   812k|    struct MPOpts *opts = mpctx->opts;
   87|   812k|    double end = rel_time_to_abs(mpctx, opts->play_end);
   88|   812k|    double length = rel_time_to_abs(mpctx, opts->play_length);
   89|   812k|    if (length != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (89:9): [True: 0, False: 812k]
  ------------------
   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|   812k|    return end;
   95|   812k|}

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

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

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

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

redraw_subs:
   57|  65.0k|{
   58|   195k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (58:21): [True: 130k, False: 65.0k]
  ------------------
   59|   130k|        if (mpctx->current_track[n][STREAM_SUB] &&
  ------------------
  |  Branch (59:13): [True: 6.66k, False: 123k]
  ------------------
   60|  6.66k|            mpctx->current_track[n][STREAM_SUB]->d_sub)
  ------------------
  |  Branch (60:13): [True: 6.66k, False: 0]
  ------------------
   61|  6.66k|        {
   62|       |            mpctx->current_track[n][STREAM_SUB]->redraw_subs = true;
   63|  6.66k|        }
   64|   130k|    }
   65|  65.0k|}
reset_subtitle_state:
   68|  32.5k|{
   69|  32.5k|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (69:21): [True: 0, False: 32.5k]
  ------------------
   70|      0|        reset_subtitles(mpctx, mpctx->tracks[n]);
   71|  32.5k|    term_osd_clear_subs(mpctx);
   72|  32.5k|}
uninit_sub:
   75|  39.5k|{
   76|  39.5k|    if (track && track->d_sub) {
  ------------------
  |  Branch (76:9): [True: 39.5k, False: 0]
  |  Branch (76:18): [True: 6.66k, False: 32.9k]
  ------------------
   77|  6.66k|        int order = get_order(mpctx, track);
   78|  6.66k|        reset_subtitles(mpctx, track);
   79|  6.66k|        sub_select(track->d_sub, false);
   80|  6.66k|        if (order >= 0) {
  ------------------
  |  Branch (80:13): [True: 6.66k, False: 0]
  ------------------
   81|  6.66k|            term_osd_set_subs(mpctx, NULL, order);
   82|  6.66k|            osd_set_sub(mpctx->osd, order, NULL);
   83|  6.66k|        }
   84|  6.66k|        sub_destroy(track->d_sub);
   85|       |        track->d_sub = NULL;
   86|  6.66k|    }
   87|  39.5k|}
uninit_sub_all:
   90|  32.5k|{
   91|  72.0k|    for (int n = 0; n < mpctx->num_tracks; n++)
  ------------------
  |  Branch (91:21): [True: 39.5k, False: 32.5k]
  ------------------
   92|  39.5k|        uninit_sub(mpctx, mpctx->tracks[n]);
   93|  32.5k|}
update_subtitles:
  166|  1.80M|{
  167|  1.80M|    bool ok = true;
  168|  5.42M|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (168:21): [True: 3.61M, False: 1.80M]
  ------------------
  169|  3.61M|        ok &= update_subtitle(mpctx, video_pts, mpctx->current_track[n][STREAM_SUB]);
  170|  1.80M|    return ok;
  171|  1.80M|}
reinit_sub:
  219|  65.0k|{
  220|  65.0k|    if (!track || !track->stream || track->stream->type != STREAM_SUB)
  ------------------
  |  Branch (220:9): [True: 58.3k, False: 6.68k]
  |  Branch (220:19): [True: 0, False: 6.68k]
  |  Branch (220:37): [True: 0, False: 6.68k]
  ------------------
  221|  58.3k|        return;
  222|       |
  223|  6.68k|    mp_assert(!track->d_sub);
  ------------------
  |  |   41|  6.68k|#define mp_assert assert
  ------------------
  |  Branch (223:5): [True: 6.68k, False: 0]
  ------------------
  224|       |
  225|  6.68k|    if (!init_subdec(mpctx, track)) {
  ------------------
  |  Branch (225:9): [True: 25, False: 6.66k]
  ------------------
  226|     25|        track->dec_failed = true;
  227|     25|        error_on_track(mpctx, track);
  228|     25|        return;
  229|     25|    }
  230|       |
  231|  6.66k|    sub_select(track->d_sub, true);
  232|  6.66k|    int order = get_order(mpctx, track);
  233|  6.66k|    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|  6.66k|    if (mpctx->playback_initialized) {
  ------------------
  |  Branch (238:9): [True: 0, False: 6.66k]
  ------------------
  239|      0|        track->demuxer_ready = false;
  240|      0|        int64_t end = mp_time_ns() + MP_TIME_MS_TO_NS(50);
  ------------------
  |  |   72|      0|#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000))
  ------------------
  241|      0|        while (!track->demuxer_ready && mp_time_ns() < end)
  ------------------
  |  Branch (241:16): [True: 0, False: 0]
  |  Branch (241:41): [True: 0, False: 0]
  ------------------
  242|      0|            track->demuxer_ready = update_subtitles(mpctx, mpctx->playback_pts) ||
  ------------------
  |  Branch (242:36): [True: 0, False: 0]
  ------------------
  243|      0|                                  !mpctx->paused;
  ------------------
  |  Branch (243:35): [True: 0, False: 0]
  ------------------
  244|      0|        if (!track->demuxer_ready)
  ------------------
  |  Branch (244:13): [True: 0, False: 0]
  ------------------
  245|      0|            mp_wakeup_core(mpctx);
  246|       |
  247|      0|    }
  248|  6.66k|}
reinit_sub_all:
  251|  32.5k|{
  252|  97.5k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++)
  ------------------
  |  Branch (252:21): [True: 65.0k, False: 32.5k]
  ------------------
  253|  65.0k|        reinit_sub(mpctx, mpctx->current_track[n][STREAM_SUB]);
  254|  32.5k|}
sub.c:reset_subtitles:
   48|  6.66k|{
   49|  6.66k|    if (track->d_sub) {
  ------------------
  |  Branch (49:9): [True: 6.66k, False: 0]
  ------------------
   50|  6.66k|        sub_reset(track->d_sub);
   51|  6.66k|        sub_set_play_dir(track->d_sub, mpctx->play_dir);
   52|  6.66k|    }
   53|  6.66k|}
sub.c:get_order:
   39|  20.0k|{
   40|  20.0k|    for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
  ------------------
  |  Branch (40:21): [True: 20.0k, False: 0]
  ------------------
   41|  20.0k|        if (mpctx->current_track[n][STREAM_SUB] == track)
  ------------------
  |  Branch (41:13): [True: 20.0k, False: 0]
  ------------------
   42|  20.0k|            return n;
   43|  20.0k|    }
   44|      0|    return -1;
   45|  20.0k|}
sub.c:update_subtitle:
   97|  3.61M|{
   98|  3.61M|    struct dec_sub *dec_sub = track ? track->d_sub : NULL;
  ------------------
  |  Branch (98:31): [True: 512k, False: 3.10M]
  ------------------
   99|       |
  100|  3.61M|    if (!dec_sub)
  ------------------
  |  Branch (100:9): [True: 3.10M, False: 512k]
  ------------------
  101|  3.10M|        return true;
  102|       |
  103|   512k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (103:9): [True: 512k, False: 0]
  ------------------
  104|   512k|        struct mp_image_params params = mpctx->vo_chain->filter->input_params;
  105|   512k|        if (params.imgfmt)
  ------------------
  |  Branch (105:13): [True: 501k, False: 11.1k]
  ------------------
  106|   501k|            sub_control(dec_sub, SD_CTRL_SET_VIDEO_PARAMS, &params);
  107|   512k|    }
  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|   512k|    bool still_image = mpctx->video_out && ((mpctx->video_status == STATUS_EOF &&
  ------------------
  |  Branch (112:24): [True: 512k, False: 0]
  |  Branch (112:46): [True: 6.66k, False: 505k]
  ------------------
  113|  6.66k|                       mpctx->opts->subs_rend->sub_past_video_end) ||
  ------------------
  |  Branch (113:24): [True: 0, False: 6.66k]
  ------------------
  114|   512k|                       !mpctx->current_track[0][STREAM_VIDEO] ||
  ------------------
  |  Branch (114:24): [True: 0, False: 512k]
  ------------------
  115|   512k|                       mpctx->current_track[0][STREAM_VIDEO]->image);
  ------------------
  |  Branch (115:24): [True: 0, False: 512k]
  ------------------
  116|   512k|    sub_control(dec_sub, SD_CTRL_SET_ANIMATED_CHECK, &still_image);
  117|       |
  118|   512k|    if (track->demuxer->fully_read && sub_can_preload(dec_sub)) {
  ------------------
  |  Branch (118:9): [True: 179k, False: 333k]
  |  Branch (118:39): [True: 2.34k, False: 176k]
  ------------------
  119|       |        // Assume fully_read implies no interleaved audio/video streams.
  120|       |        // (Reading packets will change the demuxer position.)
  121|  2.34k|        demux_seek(track->demuxer, 0, 0);
  122|  2.34k|        sub_preload(dec_sub);
  123|  2.34k|    }
  124|       |
  125|   512k|    bool packets_read = false;
  126|   512k|    bool sub_updated = false;
  127|   512k|    sub_read_packets(dec_sub, video_pts, mpctx->paused, &packets_read, &sub_updated);
  128|       |
  129|   512k|    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|   512k|    if (sub_updated || track->redraw_subs || osd_pts == MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   483k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (133:9): [True: 22.4k, False: 489k]
  |  Branch (133:24): [True: 6.65k, False: 483k]
  |  Branch (133:46): [True: 483k, False: 0]
  ------------------
  134|       |        // Always force a redecode of all packets if we seek on a still image.
  135|   512k|        if (track->redraw_subs && still_image)
  ------------------
  |  Branch (135:13): [True: 6.66k, False: 505k]
  |  Branch (135:35): [True: 0, False: 6.66k]
  ------------------
  136|      0|            sub_redecode_cached_packets(dec_sub);
  137|       |
  138|       |        // Handle displaying subtitles on terminal.
  139|   512k|        if (track->selected && track->type == STREAM_SUB && !mpctx->video_out) {
  ------------------
  |  Branch (139:13): [True: 512k, False: 0]
  |  Branch (139:32): [True: 512k, False: 0]
  |  Branch (139:61): [True: 0, False: 512k]
  ------------------
  140|      0|            char *text = sub_get_text(dec_sub, video_pts, SD_TEXT_TYPE_PLAIN);
  141|      0|            int order = get_order(mpctx, track);
  142|      0|            if (order >= 0)
  ------------------
  |  Branch (142:17): [True: 0, False: 0]
  ------------------
  143|      0|                term_osd_set_subs(mpctx, text, order);
  144|      0|            talloc_free(text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  145|      0|        }
  146|       |
  147|       |        // Handle displaying subtitles on VO with no video being played. This is
  148|       |        // quite different, because normally subtitles are redrawn on new video
  149|       |        // frames, using the video frames' timestamps.
  150|   512k|        if (still_image) {
  ------------------
  |  Branch (150:13): [True: 0, False: 512k]
  ------------------
  151|      0|            if (osd_pts != video_pts) {
  ------------------
  |  Branch (151:17): [True: 0, False: 0]
  ------------------
  152|      0|                osd_set_force_video_pts(mpctx->osd, video_pts);
  153|      0|                osd_query_and_reset_want_redraw(mpctx->osd);
  154|      0|                vo_redraw(mpctx->video_out);
  155|      0|            }
  156|      0|        }
  157|   512k|    }
  158|       |
  159|       |    track->redraw_subs = false;
  160|   512k|    return packets_read;
  161|  3.61M|}
sub.c:init_subdec:
  197|  6.68k|{
  198|  6.68k|    mp_assert(!track->d_sub);
  ------------------
  |  |   41|  6.68k|#define mp_assert assert
  ------------------
  |  Branch (198:5): [True: 6.68k, False: 0]
  ------------------
  199|       |
  200|  6.68k|    if (!track->demuxer || !track->stream)
  ------------------
  |  Branch (200:9): [True: 0, False: 6.68k]
  |  Branch (200:28): [True: 0, False: 6.68k]
  ------------------
  201|      0|        return false;
  202|       |
  203|  6.68k|    track->d_sub = sub_create(mpctx->global, track,
  204|  6.68k|                              get_all_attachments(mpctx),
  205|  6.68k|                              get_order(mpctx, track));
  206|  6.68k|    if (!track->d_sub)
  ------------------
  |  Branch (206:9): [True: 25, False: 6.66k]
  ------------------
  207|     25|        return false;
  208|       |
  209|  6.66k|    struct track *vtrack = mpctx->current_track[0][STREAM_VIDEO];
  210|  6.66k|    struct mp_codec_params *v_c =
  211|  6.66k|        vtrack && vtrack->stream ? vtrack->stream->codec : NULL;
  ------------------
  |  Branch (211:9): [True: 6.66k, False: 0]
  |  Branch (211:19): [True: 6.66k, False: 0]
  ------------------
  212|  6.66k|    double fps = v_c ? v_c->fps : 25;
  ------------------
  |  Branch (212:18): [True: 6.66k, False: 0]
  ------------------
  213|  6.66k|    sub_control(track->d_sub, SD_CTRL_SET_VIDEO_DEF_FPS, &fps);
  214|       |
  215|       |    return true;
  216|  6.68k|}
sub.c:get_all_attachments:
  174|  6.68k|{
  175|  6.68k|    struct attachment_list *list = talloc_zero(NULL, struct attachment_list);
  ------------------
  |  |   27|  6.68k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  6.68k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  6.68k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  176|  6.68k|    struct demuxer *prev_demuxer = NULL;
  177|  20.4k|    for (int n = 0; n < mpctx->num_tracks; n++) {
  ------------------
  |  Branch (177:21): [True: 13.7k, False: 6.68k]
  ------------------
  178|  13.7k|        struct track *t = mpctx->tracks[n];
  179|  13.7k|        if (!t->demuxer || prev_demuxer == t->demuxer)
  ------------------
  |  Branch (179:13): [True: 0, False: 13.7k]
  |  Branch (179:28): [True: 369, False: 13.3k]
  ------------------
  180|    369|            continue;
  181|  13.3k|        prev_demuxer = t->demuxer;
  182|  13.3k|        for (int i = 0; i < t->demuxer->num_attachments; i++) {
  ------------------
  |  Branch (182:25): [True: 0, False: 13.3k]
  ------------------
  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|  13.3k|    }
  193|  6.68k|    return list;
  194|  6.68k|}

reset_video_state:
  100|  97.5k|{
  101|  97.5k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (101:9): [True: 65.0k, False: 32.5k]
  ------------------
  102|  65.0k|        vo_chain_reset_state(mpctx->vo_chain);
  103|  65.0k|        struct track *t = mpctx->vo_chain->track;
  104|  65.0k|        if (t && t->dec)
  ------------------
  |  Branch (104:13): [True: 65.0k, False: 0]
  |  Branch (104:18): [True: 65.0k, False: 0]
  ------------------
  105|  65.0k|            mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
  106|  65.0k|    }
  107|       |
  108|  97.5k|    for (int n = 0; n < mpctx->num_next_frames; n++)
  ------------------
  |  Branch (108:21): [True: 0, False: 97.5k]
  ------------------
  109|      0|        mp_image_unrefp(&mpctx->next_frames[n]);
  110|  97.5k|    mpctx->num_next_frames = 0;
  111|  97.5k|    mp_image_unrefp(&mpctx->saved_frame);
  112|       |
  113|  97.5k|    mpctx->delay = 0;
  114|  97.5k|    mpctx->time_frame = 0;
  115|  97.5k|    mpctx->video_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  97.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  116|  97.5k|    mpctx->last_frame_duration = 0;
  117|  97.5k|    mpctx->num_past_frames = 0;
  118|  97.5k|    mpctx->total_avsync_change = 0;
  119|  97.5k|    mpctx->last_av_difference = 0;
  120|  97.5k|    mpctx->mistimed_frames_total = 0;
  121|  97.5k|    mpctx->drop_message_shown = 0;
  122|  97.5k|    mpctx->audio_drift_compensation = 0;
  123|  97.5k|    mpctx->avd_filtered = 0;
  124|  97.5k|    mpctx->display_sync_error = 0;
  125|  97.5k|    mpctx->display_sync_active = 0;
  126|       |
  127|  97.5k|    mpctx->video_status = mpctx->vo_chain ? STATUS_SYNCING : STATUS_EOF;
  ------------------
  |  Branch (127:27): [True: 65.0k, False: 32.5k]
  ------------------
  128|  97.5k|}
uninit_video_out:
  131|  97.5k|{
  132|  97.5k|    uninit_video_chain(mpctx);
  133|  97.5k|    if (mpctx->video_out) {
  ------------------
  |  Branch (133:9): [True: 32.5k, False: 65.0k]
  ------------------
  134|  32.5k|        vo_destroy(mpctx->video_out);
  135|  32.5k|        mpctx->video_out = NULL;
  136|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  137|  32.5k|    }
  138|  97.5k|}
uninit_video_chain:
  164|   130k|{
  165|   130k|    if (mpctx->vo_chain) {
  ------------------
  |  Branch (165:9): [True: 32.5k, False: 97.5k]
  ------------------
  166|  32.5k|        reset_video_state(mpctx);
  167|  32.5k|        vo_chain_uninit(mpctx->vo_chain);
  168|  32.5k|        mpctx->vo_chain = NULL;
  169|       |
  170|  32.5k|        mpctx->video_status = STATUS_EOF;
  171|       |
  172|       |        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
  173|  32.5k|    }
  174|   130k|}
init_video_decoder:
  177|  32.5k|{
  178|  32.5k|    mp_assert(!track->dec);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (178:5): [True: 32.5k, False: 0]
  ------------------
  179|  32.5k|    if (!track->stream)
  ------------------
  |  Branch (179:9): [True: 0, False: 32.5k]
  ------------------
  180|      0|        goto err_out;
  181|       |
  182|  32.5k|    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|  32.5k|    if (track->vo_c)
  ------------------
  |  Branch (189:9): [True: 32.5k, False: 0]
  ------------------
  190|  32.5k|        parent = track->vo_c->filter->f;
  191|       |
  192|  32.5k|    track->dec = mp_decoder_wrapper_create(parent, track->stream);
  193|  32.5k|    if (!track->dec)
  ------------------
  |  Branch (193:9): [True: 0, False: 32.5k]
  ------------------
  194|      0|        goto err_out;
  195|       |
  196|  32.5k|    if (sh_stream_dependent_sibling(track->stream))
  ------------------
  |  Branch (196:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    if (!mp_decoder_wrapper_reinit(track->dec))
  ------------------
  |  Branch (199:9): [True: 0, False: 32.5k]
  ------------------
  200|      0|        goto err_out;
  201|       |
  202|  32.5k|    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|  32.5k|}
reinit_video_chain:
  213|  32.5k|{
  214|  32.5k|    struct track *track = mpctx->current_track[0][STREAM_VIDEO];
  215|  32.5k|    if (!track || !track->stream) {
  ------------------
  |  Branch (215:9): [True: 0, False: 32.5k]
  |  Branch (215:19): [True: 0, False: 32.5k]
  ------------------
  216|      0|        error_on_track(mpctx, track);
  217|      0|        return;
  218|      0|    }
  219|  32.5k|    reinit_video_chain_src(mpctx, track);
  220|  32.5k|}
reinit_video_chain_src:
  272|  32.5k|{
  273|  32.5k|    mp_assert(!mpctx->vo_chain);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (273:5): [True: 32.5k, False: 0]
  ------------------
  274|       |
  275|  32.5k|    if (!mpctx->video_out) {
  ------------------
  |  Branch (275:9): [True: 32.5k, False: 0]
  ------------------
  276|  32.5k|        struct vo_extra ex = {
  277|  32.5k|            .input_ctx = mpctx->input,
  278|  32.5k|            .osd = mpctx->osd,
  279|  32.5k|            .encode_lavc_ctx = mpctx->encode_lavc_ctx,
  280|  32.5k|            .wakeup_cb = mp_wakeup_core_cb,
  281|  32.5k|            .wakeup_ctx = mpctx,
  282|  32.5k|        };
  283|  32.5k|        mpctx->video_out = init_best_video_out(mpctx->global, &ex);
  284|  32.5k|        if (!mpctx->video_out) {
  ------------------
  |  Branch (284:13): [True: 0, False: 32.5k]
  ------------------
  285|      0|            MP_FATAL(mpctx, "Error opening/initializing "
  ------------------
  |  |   88|      0|#define MP_FATAL(obj, ...)      MP_MSG(obj, MSGL_FATAL, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  286|      0|                    "the selected video_out (--vo) device.\n");
  287|      0|            mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
  288|      0|            goto err_out;
  289|      0|        }
  290|  32.5k|        mpctx->mouse_cursor_visible = true;
  291|  32.5k|    }
  292|       |
  293|  32.5k|    update_window_title(mpctx, true);
  294|       |
  295|  32.5k|    struct vo_chain *vo_c = talloc_zero(NULL, struct vo_chain);
  ------------------
  |  |   27|  32.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  32.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|  32.5k|    mpctx->vo_chain = vo_c;
  297|  32.5k|    vo_c->log = mpctx->log;
  298|  32.5k|    vo_c->vo = mpctx->video_out;
  299|  32.5k|    vo_c->filter =
  300|  32.5k|        mp_output_chain_create(mpctx->filter_root, MP_OUTPUT_CHAIN_VIDEO);
  301|  32.5k|    mp_output_chain_set_vo(vo_c->filter, vo_c->vo);
  302|  32.5k|    vo_c->filter->update_subtitles = filter_update_subtitles;
  303|  32.5k|    vo_c->filter->update_subtitles_ctx = mpctx;
  304|       |
  305|  32.5k|    if (track) {
  ------------------
  |  Branch (305:9): [True: 32.5k, False: 0]
  ------------------
  306|  32.5k|        vo_c->track = track;
  307|  32.5k|        track->vo_c = vo_c;
  308|  32.5k|        vo_c->is_coverart = !!track->attached_picture;
  309|  32.5k|        vo_c->is_sparse = track->stream->still_image || vo_c->is_coverart;
  ------------------
  |  Branch (309:27): [True: 0, False: 32.5k]
  |  Branch (309:57): [True: 0, False: 32.5k]
  ------------------
  310|  32.5k|        if (!vo_chain_init_decoder(mpctx, vo_c))
  ------------------
  |  Branch (310:13): [True: 0, False: 32.5k]
  ------------------
  311|      0|            goto err_out;
  312|  32.5k|    }
  313|       |
  314|  32.5k|    update_vo_chain_el_pair(mpctx);
  315|       |
  316|  32.5k|    if (!recreate_video_filters(mpctx))
  ------------------
  |  Branch (316:9): [True: 0, False: 32.5k]
  ------------------
  317|      0|        goto err_out;
  318|       |
  319|  32.5k|    update_content_type(mpctx, track);
  320|  32.5k|    update_screensaver_state(mpctx);
  321|       |
  322|  32.5k|    vo_set_paused(vo_c->vo, get_internal_paused(mpctx));
  323|       |
  324|  32.5k|    reset_video_state(mpctx);
  325|  32.5k|    term_osd_clear_subs(mpctx);
  326|       |
  327|  32.5k|    return;
  328|       |
  329|      0|err_out:
  330|      0|    uninit_video_chain(mpctx);
  331|      0|    error_on_track(mpctx, track);
  332|       |    handle_force_window(mpctx, true);
  333|      0|}
write_video:
 1109|   909k|{
 1110|   909k|    struct MPOpts *opts = mpctx->opts;
 1111|       |
 1112|   909k|    if (!mpctx->vo_chain)
  ------------------
  |  Branch (1112:9): [True: 0, False: 909k]
  ------------------
 1113|      0|        return;
 1114|   909k|    struct track *track = mpctx->vo_chain->track;
 1115|   909k|    struct vo_chain *vo_c = mpctx->vo_chain;
 1116|   909k|    struct vo *vo = vo_c->vo;
 1117|       |
 1118|   909k|    if (vo_c->filter->reconfig_happened) {
  ------------------
  |  Branch (1118:9): [True: 32.5k, False: 876k]
  ------------------
 1119|  32.5k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1120|  32.5k|        vo_c->filter->reconfig_happened = false;
 1121|  32.5k|    }
 1122|       |
 1123|       |    // Actual playback starts when both audio and video are ready.
 1124|   909k|    if (mpctx->video_status == STATUS_READY)
  ------------------
  |  Branch (1124:9): [True: 0, False: 909k]
  ------------------
 1125|      0|        return;
 1126|       |
 1127|   909k|    if (mpctx->paused && mpctx->video_status >= STATUS_READY)
  ------------------
  |  Branch (1127:9): [True: 8, False: 909k]
  |  Branch (1127:26): [True: 8, False: 0]
  ------------------
 1128|      8|        return;
 1129|       |
 1130|       |    // Once the chain reached EOF nothing is read from it again.
 1131|   909k|    bool logical_eof = false;
 1132|   909k|    int r = VD_EOF;
 1133|   909k|    if (mpctx->video_status < STATUS_DRAINING)
  ------------------
  |  Branch (1133:9): [True: 909k, False: 121]
  ------------------
 1134|   909k|        r = video_output_image(mpctx, &logical_eof);
 1135|   909k|    MP_TRACE(mpctx, "video_output_image: r=%d/eof=%d/st=%s\n", r, logical_eof,
  ------------------
  |  |   94|   909k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   909k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1136|   909k|             mp_status_str(mpctx->video_status));
 1137|       |
 1138|   909k|    if (r < 0)
  ------------------
  |  Branch (1138:9): [True: 0, False: 909k]
  ------------------
 1139|      0|        goto error;
 1140|       |
 1141|   909k|    if (r == VD_WAIT) {
  ------------------
  |  Branch (1141:9): [True: 60.9k, False: 848k]
  ------------------
 1142|       |        // Heuristic to detect underruns.
 1143|  60.9k|        if (mpctx->video_status == STATUS_PLAYING && !vo_still_displaying(vo) &&
  ------------------
  |  Branch (1143:13): [True: 88, False: 60.8k]
  |  Branch (1143:54): [True: 88, False: 0]
  ------------------
 1144|     88|            !vo_c->underrun_signaled)
  ------------------
  |  Branch (1144:13): [True: 88, False: 0]
  ------------------
 1145|     88|        {
 1146|     88|            vo_c->underrun = true;
 1147|     88|            vo_c->underrun_signaled = true;
 1148|     88|        }
 1149|       |        // Demuxer will wake us up for more packets to decode.
 1150|  60.9k|        return;
 1151|  60.9k|    }
 1152|       |
 1153|   848k|    if (r == VD_EOF) {
  ------------------
  |  Branch (1153:9): [True: 32.6k, False: 815k]
  ------------------
 1154|  32.6k|        if (check_for_hwdec_fallback(mpctx))
  ------------------
  |  Branch (1154:13): [True: 0, False: 32.6k]
  ------------------
 1155|      0|            return;
 1156|  32.6k|        if (check_for_forced_eof(mpctx)) {
  ------------------
  |  Branch (1156:13): [True: 0, False: 32.6k]
  ------------------
 1157|      0|            uninit_video_chain(mpctx);
 1158|      0|            handle_force_window(mpctx, true);
 1159|      0|            return;
 1160|      0|        }
 1161|  32.6k|        if (vo_c->filter->failed_output_conversion)
  ------------------
  |  Branch (1161:13): [True: 0, False: 32.6k]
  ------------------
 1162|      0|            goto error;
 1163|       |
 1164|  32.6k|        mpctx->delay = 0;
 1165|  32.6k|        mpctx->last_av_difference = 0;
 1166|       |
 1167|  32.6k|        if (mpctx->video_status <= STATUS_PLAYING) {
  ------------------
  |  Branch (1167:13): [True: 32.5k, False: 121]
  ------------------
 1168|  32.5k|            mpctx->video_status = STATUS_DRAINING;
 1169|  32.5k|            get_relative_time(mpctx);
 1170|  32.5k|            if (vo_c->is_sparse && !mpctx->ao_chain) {
  ------------------
  |  Branch (1170:17): [True: 0, False: 32.5k]
  |  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|  32.5k|            } else if (mpctx->last_frame_duration > 0 && !opts->untimed &&
  ------------------
  |  Branch (1173:24): [True: 32.5k, False: 0]
  |  Branch (1173:58): [True: 0, False: 32.5k]
  ------------------
 1174|      0|                       !(vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (1174:24): [True: 0, False: 0]
  ------------------
 1175|      0|            {
 1176|      0|                MP_VERBOSE(mpctx, "using demuxer frame duration for last frame\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1177|      0|                mpctx->time_frame += mpctx->last_frame_duration;
 1178|  32.5k|            } else {
 1179|  32.5k|                mpctx->time_frame = 0;
 1180|  32.5k|            }
 1181|       |            // Encode mode can't honor this; it'll only delay finishing.
 1182|  32.5k|            if (mpctx->encode_lavc_ctx)
  ------------------
  |  Branch (1182:17): [True: 0, False: 32.5k]
  ------------------
 1183|      0|                mpctx->time_frame = 0;
 1184|  32.5k|        }
 1185|       |
 1186|       |        // Wait for the VO to signal actual EOF, then exit if the frame timer
 1187|       |        // has expired.
 1188|  32.6k|        bool has_frame = vo_has_frame(vo); // maybe not configured
 1189|  32.6k|        if (mpctx->video_status == STATUS_DRAINING &&
  ------------------
  |  Branch (1189:13): [True: 32.6k, False: 0]
  ------------------
 1190|  32.6k|            (vo_is_ready_for_frame(vo, -1) || !has_frame))
  ------------------
  |  Branch (1190:14): [True: 32.5k, False: 121]
  |  Branch (1190:47): [True: 0, False: 121]
  ------------------
 1191|  32.5k|        {
 1192|  32.5k|            mpctx->time_frame -= get_relative_time(mpctx);
 1193|  32.5k|            mp_set_timeout(mpctx, mpctx->time_frame);
 1194|  32.5k|            if (mpctx->time_frame <= 0 || !has_frame) {
  ------------------
  |  Branch (1194:17): [True: 32.5k, False: 0]
  |  Branch (1194:43): [True: 0, False: 0]
  ------------------
 1195|  32.5k|                MP_VERBOSE(mpctx, "video EOF reached\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1196|  32.5k|                mpctx->video_status = STATUS_EOF;
 1197|  32.5k|            }
 1198|  32.5k|        }
 1199|       |
 1200|       |        // Avoid pointlessly spamming the logs every frame.
 1201|  32.6k|        if (!vo_c->is_sparse || !vo_c->sparse_eof_signalled) {
  ------------------
  |  Branch (1201:13): [True: 32.6k, False: 0]
  |  Branch (1201:33): [True: 0, False: 0]
  ------------------
 1202|  32.6k|            MP_DBG(mpctx, "video EOF (status=%d)\n", mpctx->video_status);
  ------------------
  |  |   93|  32.6k|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.6k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1203|  32.6k|            vo_c->sparse_eof_signalled = vo_c->is_sparse;
 1204|  32.6k|        }
 1205|  32.6k|        return;
 1206|  32.6k|    }
 1207|       |
 1208|   815k|    if (r != VD_NEW_FRAME) {
  ------------------
  |  Branch (1208:9): [True: 0, False: 815k]
  ------------------
 1209|      0|        mp_wakeup_core(mpctx); // Decode more in next iteration.
 1210|      0|        return;
 1211|      0|    }
 1212|       |
 1213|       |    // A sparse still-image stream may have no frame at the seek target.
 1214|       |    // Complete the restart without showing it.
 1215|   815k|    if (vo_c->is_sparse && mpctx->video_status < STATUS_READY) {
  ------------------
  |  Branch (1215:9): [True: 0, False: 815k]
  |  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|   815k|    if (logical_eof && !mpctx->num_past_frames && mpctx->num_next_frames == 1 &&
  ------------------
  |  Branch (1227:9): [True: 0, False: 815k]
  |  Branch (1227:24): [True: 0, False: 0]
  |  Branch (1227:51): [True: 0, False: 0]
  ------------------
 1228|      0|        use_video_lookahead(mpctx) && !vo_c->is_sparse)
  ------------------
  |  Branch (1228:9): [True: 0, False: 0]
  |  Branch (1228:39): [True: 0, False: 0]
  ------------------
 1229|      0|    {
 1230|       |        // Too much danger to accidentally mark video as sparse when e.g.
 1231|       |        // seeking exactly to the last frame, so as a heuristic, do this only
 1232|       |        // if it looks like the "first" video frame (unreliable, but often
 1233|       |        // works out well). Helps with seeking with single-image video tracks,
 1234|       |        // as well as detecting whether as video track is really an image.
 1235|      0|        if (mpctx->next_frames[0]->pts == 0) {
  ------------------
  |  Branch (1235:13): [True: 0, False: 0]
  ------------------
 1236|      0|            MP_VERBOSE(mpctx, "assuming single-image video stream\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1237|      0|            vo_c->is_sparse = true;
 1238|      0|        }
 1239|      0|    }
 1240|       |
 1241|       |    // Inject vo crop to notify and reconfig if needed
 1242|   815k|    apply_video_crop(mpctx, vo);
 1243|       |
 1244|       |    // Filter output is different from VO input?
 1245|   815k|    struct mp_image_params *p = &mpctx->next_frames[0]->params;
 1246|   815k|    if (!vo->params || !mp_image_params_static_equal(p, vo->params)) {
  ------------------
  |  Branch (1246:9): [True: 32.5k, False: 783k]
  |  Branch (1246:24): [True: 0, False: 783k]
  ------------------
 1247|       |        // Changing config deletes the current frame; wait until it's finished.
 1248|  32.5k|        if (vo_still_displaying(vo)) {
  ------------------
  |  Branch (1248:13): [True: 0, False: 32.5k]
  ------------------
 1249|      0|            vo_request_wakeup_on_done(vo);
 1250|      0|            return;
 1251|      0|        }
 1252|       |
 1253|  32.5k|        const struct vo_driver *info = mpctx->video_out->driver;
 1254|  32.5k|        char extra[20] = {0};
 1255|  32.5k|        if (p->p_w != p->p_h) {
  ------------------
  |  Branch (1255:13): [True: 0, False: 32.5k]
  ------------------
 1256|      0|            int d_w, d_h;
 1257|      0|            mp_image_params_get_dsize(p, &d_w, &d_h);
 1258|      0|            snprintf(extra, sizeof(extra), " => %dx%d", d_w, d_h);
 1259|      0|        }
 1260|  32.5k|        char sfmt[20] = {0};
 1261|  32.5k|        if (p->hw_subfmt)
  ------------------
  |  Branch (1261:13): [True: 0, False: 32.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|  32.5k|        MP_INFO(mpctx, "VO: [%s] %dx%d%s %s%s\n",
  ------------------
  |  |   91|  32.5k|#define MP_INFO(obj, ...)       MP_MSG(obj, MSGL_INFO, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1264|  32.5k|                info->name, p->w, p->h, extra, mp_imgfmt_to_name(p->imgfmt), sfmt);
 1265|  32.5k|        MP_VERBOSE(mpctx, "VO: Description: %s\n", info->description);
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1266|       |
 1267|  32.5k|        int vo_r = vo_reconfig2(vo, mpctx->next_frames[0]);
 1268|  32.5k|        if (vo_r < 0) {
  ------------------
  |  Branch (1268:13): [True: 0, False: 32.5k]
  ------------------
 1269|      0|            mpctx->error_playing = MPV_ERROR_VO_INIT_FAILED;
 1270|      0|            goto error;
 1271|      0|        }
 1272|  32.5k|        mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
 1273|   783k|    } else {
 1274|       |        // Update parameters that don't require reconfiguring the VO.
 1275|   783k|        mp_mutex_lock(&vo->params_mutex);
  ------------------
  |  |  134|   783k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
 1276|   783k|        mp_image_params_update_dynamic(vo->params, p, vo->has_peak_detect_values);
 1277|   783k|        mp_mutex_unlock(&vo->params_mutex);
  ------------------
  |  |  136|   783k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
 1278|   783k|    }
 1279|       |
 1280|   815k|    mpctx->time_frame -= get_relative_time(mpctx);
 1281|   815k|    update_avsync_before_frame(mpctx);
 1282|       |
 1283|       |    // Enforce timing subtitles to video frames.
 1284|   815k|    osd_set_force_video_pts(mpctx->osd, MP_NOPTS_VALUE);
  ------------------
  |  |   39|   815k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
 1285|       |
 1286|   815k|    if (!update_subtitles(mpctx, mpctx->next_frames[0]->pts)) {
  ------------------
  |  Branch (1286:9): [True: 171, False: 815k]
  ------------------
 1287|    171|        MP_VERBOSE(mpctx, "Video frame delayed due to waiting on subtitles.\n");
  ------------------
  |  |   92|    171|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    171|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1288|    171|        return;
 1289|    171|    }
 1290|       |
 1291|   815k|    double time_frame = MPMAX(mpctx->time_frame, -1);
  ------------------
  |  |   44|   815k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 815k, False: 0]
  |  |  ------------------
  ------------------
 1292|   815k|    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|   815k|    if (!vo_is_ready_for_frame(vo, mpctx->display_sync_active ? -1 : pts))
  ------------------
  |  Branch (1297:9): [True: 2.55k, False: 812k]
  |  Branch (1297:36): [True: 0, False: 815k]
  ------------------
 1298|  2.55k|        return;
 1299|       |
 1300|       |    // In encoding mode, wait for the ao to finish initializing.
 1301|   812k|    if (mpctx->encode_lavc_ctx && mpctx->current_track[0][STREAM_AUDIO] && !mpctx->ao)
  ------------------
  |  Branch (1301:9): [True: 0, False: 812k]
  |  Branch (1301:35): [True: 0, False: 0]
  |  Branch (1301:76): [True: 0, False: 0]
  ------------------
 1302|      0|        return;
 1303|       |
 1304|   812k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|   812k|#define mp_assert assert
  ------------------
  |  Branch (1304:5): [True: 812k, False: 0]
  ------------------
 1305|       |
 1306|   812k|    if (mpctx->num_past_frames >= MAX_NUM_VO_PTS)
  ------------------
  |  Branch (1306:9): [True: 0, False: 812k]
  ------------------
 1307|      0|        mpctx->num_past_frames--;
 1308|   812k|    MP_TARRAY_INSERT_AT(mpctx, mpctx->past_frames, mpctx->num_past_frames, 0,
  ------------------
  |  |  115|   812k|    do {                                            \
  |  |  116|   812k|        size_t at_ = (at);                          \
  |  |  117|   812k|        assert(at_ <= (idxvar));                    \
  |  |  118|   812k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   812k|    do {                                            \
  |  |  |  |   97|   812k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   812k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   812k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   812k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 130k, False: 682k]
  |  |  |  |  ------------------
  |  |  |  |   99|   812k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|   130k|    do {                                                        \
  |  |  |  |  |  |   89|   130k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|   130k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|   130k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|   130k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|   130k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|   130k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|   130k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 130k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   812k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 812k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|   812k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|   812k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|   812k|        (idxvar)++;                                 \
  |  |  122|   812k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|   812k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 812k]
  |  |  ------------------
  ------------------
  |  Branch (1308:5): [True: 812k, False: 0]
  ------------------
 1309|   812k|                        (struct frame_info){0});
 1310|   812k|    mpctx->past_frames[0] = (struct frame_info){
 1311|   812k|        .pts = mpctx->next_frames[0]->pts,
 1312|   812k|        .num_vsyncs = -1,
 1313|   812k|    };
 1314|   812k|    calculate_frame_duration(mpctx);
 1315|       |
 1316|   812k|    int req = vo_get_num_req_frames(mpctx->video_out);
 1317|   812k|    mp_assert(req >= 1 && req <= VO_MAX_REQ_FRAMES);
  ------------------
  |  |   41|   812k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 812k, False: 0]
  |  Branch (1317:5): [True: 812k, False: 0]
  ------------------
 1318|   812k|    struct vo_frame dummy = {
 1319|   812k|        .pts = pts,
 1320|   812k|        .duration = -1,
 1321|   812k|        .still = mpctx->step_frames > 0,
 1322|   812k|        .can_drop = opts->frame_dropping & 1,
 1323|   812k|        .num_frames = MPMIN(mpctx->num_next_frames, req),
  ------------------
  |  |   45|   812k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 812k]
  |  |  ------------------
  ------------------
 1324|   812k|        .num_vsyncs = 1,
 1325|   812k|    };
 1326|  1.62M|    for (int n = 0; n < dummy.num_frames; n++)
  ------------------
  |  Branch (1326:21): [True: 812k, False: 812k]
  ------------------
 1327|   812k|        dummy.frames[n] = mpctx->next_frames[n];
 1328|   812k|    struct vo_frame *frame = vo_frame_ref(&dummy);
 1329|       |
 1330|   812k|    double diff = mpctx->past_frames[0].approx_duration;
 1331|   812k|    if (opts->untimed || (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (1331:9): [True: 812k, False: 0]
  |  Branch (1331:26): [True: 0, False: 0]
  ------------------
 1332|   812k|        diff = -1; // disable frame dropping and aspects of frame timing
 1333|   812k|    if (diff >= 0) {
  ------------------
  |  Branch (1333:9): [True: 0, False: 812k]
  ------------------
 1334|      0|        diff /= mpctx->video_speed;
 1335|      0|        frame->duration = MP_TIME_S_TO_NS(MPCLAMP(diff, 0, 10));
  ------------------
  |  |   71|      0|#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000))
  |  |  ------------------
  |  |  |  Branch (71:30): [True: 0, False: 0]
  |  |  |  Branch (71:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1336|      0|    }
 1337|       |
 1338|   812k|    mpctx->video_pts = mpctx->next_frames[0]->pts;
 1339|   812k|    mpctx->video_pts_unrounded = mpctx->next_pts_unrounded;
 1340|   812k|    mpctx->last_frame_duration =
 1341|   812k|        mpctx->next_frames[0]->pkt_duration / mpctx->video_speed;
 1342|       |
 1343|   812k|    shift_frames(mpctx);
 1344|       |
 1345|   812k|    schedule_frame(mpctx, frame);
 1346|       |
 1347|   812k|    mpctx->osd_force_update = true;
 1348|   812k|    update_osd_msg(mpctx);
 1349|       |
 1350|   812k|    vo_queue_frame(vo, frame);
 1351|       |
 1352|   812k|    check_framedrop(mpctx, vo_c);
 1353|       |
 1354|       |    // The frames were shifted down; "initialize" the new first entry.
 1355|   812k|    if (mpctx->num_next_frames >= 1)
  ------------------
  |  Branch (1355:9): [True: 0, False: 812k]
  ------------------
 1356|      0|        handle_new_frame(mpctx);
 1357|       |
 1358|   812k|    mpctx->shown_vframes++;
 1359|   812k|    if (mpctx->video_status < STATUS_PLAYING) {
  ------------------
  |  Branch (1359:9): [True: 32.5k, False: 780k]
  ------------------
 1360|  32.5k|        mpctx->video_status = STATUS_READY;
 1361|       |        // After a seek, make sure to wait until the first frame is visible.
 1362|  32.5k|        if (!opts->video_latency_hacks) {
  ------------------
  |  Branch (1362:13): [True: 32.5k, False: 0]
  ------------------
 1363|  32.5k|            vo_wait_frame(vo);
 1364|  32.5k|            MP_VERBOSE(mpctx, "first video frame after restart shown\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1365|  32.5k|        }
 1366|  32.5k|    }
 1367|       |
 1368|   812k|    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|   812k|    if (logical_eof && !mpctx->num_next_frames && mpctx->ao_chain)
  ------------------
  |  Branch (1373:9): [True: 0, False: 812k]
  |  Branch (1373:24): [True: 0, False: 0]
  |  Branch (1373:51): [True: 0, False: 0]
  ------------------
 1374|      0|        mpctx->video_status = STATUS_EOF;
 1375|       |
 1376|   812k|    if (mpctx->video_status != STATUS_EOF) {
  ------------------
  |  Branch (1376:9): [True: 812k, False: 0]
  ------------------
 1377|   812k|        if (mpctx->step_frames > 0) {
  ------------------
  |  Branch (1377:13): [True: 0, False: 812k]
  ------------------
 1378|      0|            mpctx->step_frames--;
 1379|      0|            if (!mpctx->step_frames) {
  ------------------
  |  Branch (1379:17): [True: 0, False: 0]
  ------------------
 1380|      0|                set_pause_state(mpctx, true);
 1381|      0|                step_frame_mute(mpctx, false);
 1382|      0|            }
 1383|      0|        }
 1384|   812k|        if (mpctx->max_frames == 0 && !mpctx->stop_play)
  ------------------
  |  Branch (1384:13): [True: 0, False: 812k]
  |  Branch (1384:39): [True: 0, False: 0]
  ------------------
 1385|      0|            mpctx->stop_play = AT_END_OF_FILE;
 1386|   812k|        if (mpctx->max_frames > 0)
  ------------------
  |  Branch (1386:13): [True: 0, False: 812k]
  ------------------
 1387|      0|            mpctx->max_frames--;
 1388|   812k|    }
 1389|       |
 1390|   812k|    vo_c->underrun_signaled = false;
 1391|       |
 1392|   812k|    if (mpctx->video_status == STATUS_EOF || mpctx->stop_play)
  ------------------
  |  Branch (1392:9): [True: 0, False: 812k]
  |  Branch (1392:46): [True: 0, False: 812k]
  ------------------
 1393|      0|        mp_wakeup_core(mpctx);
 1394|   812k|    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|  32.5k|{
   68|  32.5k|    struct MPOpts *opts = mpctx->opts;
   69|  32.5k|    struct vo_chain *vo_c = mpctx->vo_chain;
   70|  32.5k|    mp_assert(vo_c);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (70:5): [True: 32.5k, False: 0]
  ------------------
   71|       |
   72|  32.5k|    return mp_output_chain_update_filters(vo_c->filter, opts->vf_settings);
   73|  32.5k|}
video.c:vo_chain_reset_state:
   93|  65.0k|{
   94|  65.0k|    vo_seek_reset(vo_c->vo);
   95|  65.0k|    vo_c->underrun = false;
   96|       |    vo_c->underrun_signaled = false;
   97|  65.0k|}
video.c:vo_chain_uninit:
  141|  32.5k|{
  142|  32.5k|    struct track *track = vo_c->track;
  143|  32.5k|    if (track) {
  ------------------
  |  Branch (143:9): [True: 32.5k, False: 0]
  ------------------
  144|  32.5k|        mp_assert(track->vo_c == vo_c);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (144:9): [True: 32.5k, False: 0]
  ------------------
  145|  32.5k|        track->vo_c = NULL;
  146|  32.5k|        if (vo_c->dec_src)
  ------------------
  |  Branch (146:13): [True: 32.5k, False: 0]
  ------------------
  147|  32.5k|            mp_assert(track->dec->f->pins[0] == vo_c->dec_src);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (147:13): [True: 32.5k, False: 0]
  ------------------
  148|       |        // This is NULL if a sh_stream_group's filter fails.
  149|  32.5k|        if (track->dec) {
  ------------------
  |  Branch (149:13): [True: 32.5k, False: 0]
  ------------------
  150|  32.5k|            talloc_free(track->dec->f);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  151|  32.5k|            track->dec = NULL;
  152|  32.5k|        }
  153|  32.5k|    }
  154|       |
  155|  32.5k|    if (vo_c->filter_src)
  ------------------
  |  Branch (155:9): [True: 0, False: 32.5k]
  ------------------
  156|      0|        mp_pin_disconnect(vo_c->filter_src);
  157|       |
  158|  32.5k|    talloc_free(vo_c->filter->f);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  159|  32.5k|    talloc_free(vo_c);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  160|       |    // this does not free the VO
  161|  32.5k|}
video.c:vo_chain_init_decoder:
  232|  32.5k|{
  233|  32.5k|    struct track *track = vo_c->track;
  234|  32.5k|    if (!init_video_decoder(mpctx, track))
  ------------------
  |  Branch (234:9): [True: 0, False: 32.5k]
  ------------------
  235|      0|        return false;
  236|  32.5k|    vo_c->dec_src = track->dec->f->pins[0];
  237|  32.5k|    vo_c->filter->container_fps =
  238|  32.5k|        mp_decoder_wrapper_get_container_fps(track->dec);
  239|  32.5k|    if (vo_c->is_coverart)
  ------------------
  |  Branch (239:9): [True: 0, False: 32.5k]
  ------------------
  240|      0|        mp_decoder_wrapper_set_coverart_flag(track->dec, true);
  241|  32.5k|    mp_pin_connect(vo_c->filter->f->pins[0], vo_c->dec_src);
  242|       |    return true;
  243|  32.5k|}
video.c:filter_update_subtitles:
  223|   812k|{
  224|   812k|    struct MPContext *mpctx = ctx;
  225|       |
  226|   812k|    if (osd_get_render_subs_in_filter(mpctx->osd))
  ------------------
  |  Branch (226:9): [True: 780k, False: 32.5k]
  ------------------
  227|   780k|        update_subtitles(mpctx, pts);
  228|   812k|}
video.c:video_output_image:
  520|   909k|{
  521|   909k|    struct vo_chain *vo_c = mpctx->vo_chain;
  522|   909k|    bool hrseek = false;
  523|   909k|    double hrseek_pts = mpctx->hrseek_pts;
  524|   909k|    double tolerance = mpctx->hrseek_backstep ? 0 : .005;
  ------------------
  |  Branch (524:24): [True: 0, False: 909k]
  ------------------
  525|   909k|    if (mpctx->video_status == STATUS_SYNCING) {
  ------------------
  |  Branch (525:9): [True: 93.5k, False: 815k]
  ------------------
  526|  93.5k|        hrseek = mpctx->hrseek_active;
  527|       |        // playback_pts is normally only set when audio and video have started
  528|       |        // playing normally. If video is in syncing mode, then this must mean
  529|       |        // video was just enabled via track switching - skip to current time.
  530|  93.5k|        if (!hrseek && mpctx->playback_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  93.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (530:13): [True: 93.5k, False: 0]
  |  Branch (530:24): [True: 0, False: 93.5k]
  ------------------
  531|      0|            hrseek = true;
  532|      0|            hrseek_pts = mpctx->playback_pts;
  533|      0|        }
  534|  93.5k|    }
  535|       |
  536|   909k|    if (vo_c->is_coverart) {
  ------------------
  |  Branch (536:9): [True: 0, False: 909k]
  ------------------
  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|   909k|    if (vo_c->is_sparse)
  ------------------
  |  Branch (545:9): [True: 0, False: 909k]
  ------------------
  546|      0|        hrseek = false;
  547|       |
  548|   909k|    if (have_new_frame(mpctx, false))
  ------------------
  |  Branch (548:9): [True: 2.73k, False: 906k]
  ------------------
  549|  2.73k|        return VD_NEW_FRAME;
  550|       |
  551|       |    // Get a new frame if we need one.
  552|   906k|    int r = VD_PROGRESS;
  553|   906k|    if (needs_new_frame(mpctx)) {
  ------------------
  |  Branch (553:9): [True: 906k, False: 0]
  ------------------
  554|       |        // Filter a new frame.
  555|   906k|        struct mp_image *img = NULL;
  556|   906k|        struct mp_frame frame = mp_pin_out_read(vo_c->filter->f->pins[1]);
  557|   906k|        if (frame.type == MP_FRAME_NONE) {
  ------------------
  |  Branch (557:13): [True: 60.9k, False: 845k]
  ------------------
  558|  60.9k|            r = vo_c->filter->got_output_eof ? VD_EOF : VD_WAIT;
  ------------------
  |  Branch (558:17): [True: 0, False: 60.9k]
  ------------------
  559|   845k|        } else if (frame.type == MP_FRAME_EOF) {
  ------------------
  |  Branch (559:20): [True: 32.5k, False: 812k]
  ------------------
  560|  32.5k|            r = VD_EOF;
  561|   812k|        } else if (frame.type == MP_FRAME_VIDEO) {
  ------------------
  |  Branch (561:20): [True: 812k, False: 0]
  ------------------
  562|   812k|            img = frame.data;
  563|   812k|        } 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|   906k|        if (img) {
  ------------------
  |  Branch (569:13): [True: 812k, False: 93.4k]
  ------------------
  570|   812k|            double endpts = get_play_end_pts(mpctx);
  571|   812k|            if (endpts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (571:17): [True: 0, False: 812k]
  ------------------
  572|      0|                endpts *= mpctx->play_dir;
  573|   812k|            if ((endpts != MP_NOPTS_VALUE && img->pts >= endpts) ||
  ------------------
  |  |   39|  1.62M|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (573:18): [True: 0, False: 812k]
  |  Branch (573:46): [True: 0, False: 0]
  ------------------
  574|   812k|                mpctx->max_frames == 0)
  ------------------
  |  Branch (574:17): [True: 0, False: 812k]
  ------------------
  575|      0|            {
  576|      0|                mp_pin_out_unread(vo_c->filter->f->pins[1], frame);
  577|      0|                img = NULL;
  578|      0|                r = VD_EOF;
  579|   812k|            } else if (hrseek && (img->pts < hrseek_pts - tolerance ||
  ------------------
  |  Branch (579:24): [True: 0, False: 812k]
  |  Branch (579:35): [True: 0, False: 0]
  ------------------
  580|      0|                                  mpctx->hrseek_lastframe))
  ------------------
  |  Branch (580:35): [True: 0, False: 0]
  ------------------
  581|      0|            {
  582|       |                /* just skip - but save in case it was the last frame */
  583|      0|                mp_image_setrefp(&mpctx->saved_frame, img);
  584|   812k|            } else {
  585|   812k|                if (hrseek && mpctx->hrseek_backstep) {
  ------------------
  |  Branch (585:21): [True: 0, False: 812k]
  |  Branch (585:31): [True: 0, False: 0]
  ------------------
  586|      0|                    if (mpctx->saved_frame) {
  ------------------
  |  Branch (586:25): [True: 0, False: 0]
  ------------------
  587|      0|                        add_new_frame(mpctx, mpctx->saved_frame);
  588|      0|                        mpctx->saved_frame = NULL;
  589|      0|                    } else {
  590|      0|                        MP_WARN(mpctx, "Backstep failed.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  591|      0|                    }
  592|      0|                    mpctx->hrseek_backstep = false;
  593|      0|                }
  594|   812k|                mp_image_unrefp(&mpctx->saved_frame);
  595|   812k|                add_new_frame(mpctx, img);
  596|   812k|                img = NULL;
  597|   812k|            }
  598|   812k|            talloc_free(img);
  ------------------
  |  |   47|   812k|#define talloc_free                     ta_free
  ------------------
  599|   812k|        }
  600|   906k|    }
  601|       |
  602|   906k|    if (!hrseek)
  ------------------
  |  Branch (602:9): [True: 906k, False: 0]
  ------------------
  603|   906k|        mp_image_unrefp(&mpctx->saved_frame);
  604|       |
  605|   906k|    if (r == VD_EOF) {
  ------------------
  |  Branch (605:9): [True: 32.5k, False: 873k]
  ------------------
  606|       |        // If hr-seek went past EOF, use the last frame.
  607|  32.5k|        if (mpctx->saved_frame)
  ------------------
  |  Branch (607:13): [True: 0, False: 32.5k]
  ------------------
  608|      0|            add_new_frame(mpctx, mpctx->saved_frame);
  609|  32.5k|        mpctx->saved_frame = NULL;
  610|  32.5k|        *logical_eof = true;
  611|  32.5k|    }
  612|       |
  613|   906k|    return have_new_frame(mpctx, r <= 0) ? VD_NEW_FRAME : r;
  ------------------
  |  Branch (613:12): [True: 812k, False: 93.4k]
  ------------------
  614|   906k|}
video.c:have_new_frame:
  512|  1.81M|{
  513|  1.81M|    return mpctx->num_next_frames >= get_req_frames(mpctx, eof);
  514|  1.81M|}
video.c:get_req_frames:
  471|  2.72M|{
  472|       |    // On EOF, drain all frames.
  473|  2.72M|    if (eof)
  ------------------
  |  Branch (473:9): [True: 32.5k, False: 2.68M]
  ------------------
  474|  32.5k|        return 1;
  475|       |
  476|  2.68M|    if (!use_video_lookahead(mpctx))
  ------------------
  |  Branch (476:9): [True: 2.68M, False: 0]
  ------------------
  477|  2.68M|        return 1;
  478|       |
  479|      0|    if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
  ------------------
  |  Branch (479:9): [True: 0, False: 0]
  |  Branch (479:28): [True: 0, False: 0]
  ------------------
  480|      0|        return 1;
  481|       |
  482|       |    // Normally require at least 2 frames, so we can compute a frame duration.
  483|      0|    int min = 2;
  484|       |
  485|       |    // On the first frame, output a new frame as quickly as possible.
  486|      0|    if (mpctx->video_pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (486:9): [True: 0, False: 0]
  ------------------
  487|      0|        return min;
  488|       |
  489|      0|    int req = vo_get_num_req_frames(mpctx->video_out);
  490|      0|    return MPCLAMP(req, min, MP_ARRAY_SIZE(mpctx->next_frames) - 1);
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  491|      0|}
video.c:needs_new_frame:
  495|   906k|{
  496|       |    return mpctx->num_next_frames < get_req_frames(mpctx, false);
  497|   906k|}
video.c:add_new_frame:
  501|   812k|{
  502|   812k|    mp_assert(mpctx->num_next_frames < MP_ARRAY_SIZE(mpctx->next_frames));
  ------------------
  |  |   41|   812k|#define mp_assert assert
  ------------------
  |  Branch (502:5): [True: 812k, False: 0]
  ------------------
  503|   812k|    mp_assert(frame);
  ------------------
  |  |   41|   812k|#define mp_assert assert
  ------------------
  |  Branch (503:5): [True: 812k, False: 0]
  ------------------
  504|   812k|    mpctx->next_frames[mpctx->num_next_frames++] = frame;
  505|   812k|    if (mpctx->num_next_frames == 1)
  ------------------
  |  Branch (505:9): [True: 812k, False: 0]
  ------------------
  506|   812k|        handle_new_frame(mpctx);
  507|   812k|}
video.c:check_for_hwdec_fallback:
  617|  32.6k|{
  618|  32.6k|    struct vo_chain *vo_c = mpctx->vo_chain;
  619|       |
  620|  32.6k|    if (!vo_c->filter->failed_output_conversion || !vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (620:9): [True: 32.6k, False: 0]
  |  Branch (620:52): [True: 0, False: 0]
  |  Branch (620:68): [True: 0, False: 0]
  ------------------
  621|  32.6k|        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|  32.6k|{
  633|  32.6k|    struct vo_chain *vo_c = mpctx->vo_chain;
  634|       |
  635|  32.6k|    if (!vo_c->track || !vo_c->track->dec)
  ------------------
  |  Branch (635:9): [True: 0, False: 32.6k]
  |  Branch (635:25): [True: 0, False: 32.6k]
  ------------------
  636|      0|        return false;
  637|       |
  638|  32.6k|    struct mp_decoder_wrapper *dec = vo_c->track->dec;
  639|  32.6k|    bool forced_eof = false;
  640|       |
  641|  32.6k|    mp_decoder_wrapper_control(dec, VDCTRL_CHECK_FORCED_EOF, &forced_eof);
  642|  32.6k|    return forced_eof;
  643|  32.6k|}
video.c:use_video_lookahead:
  463|  2.68M|{
  464|  2.68M|    return mpctx->video_out &&
  ------------------
  |  Branch (464:12): [True: 2.68M, False: 0]
  ------------------
  465|  2.68M|           !(mpctx->video_out->driver->caps & VO_CAP_NORETAIN) &&
  ------------------
  |  Branch (465:12): [True: 2.68M, False: 0]
  ------------------
  466|  2.68M|           !(mpctx->opts->untimed || (mpctx->video_out->driver->caps & VO_CAP_UNTIMED)) &&
  ------------------
  |  Branch (466:14): [True: 2.68M, False: 0]
  |  Branch (466:38): [True: 0, False: 0]
  ------------------
  467|      0|           !mpctx->opts->video_latency_hacks;
  ------------------
  |  Branch (467:12): [True: 0, False: 0]
  ------------------
  468|  2.68M|}
video.c:apply_video_crop:
 1083|   815k|{
 1084|  1.63M|    for (int n = 0; n < mpctx->num_next_frames; n++) {
  ------------------
  |  Branch (1084:21): [True: 815k, False: 815k]
  ------------------
 1085|   815k|        struct m_geometry *gm = &vo->opts->video_crop;
 1086|   815k|        struct mp_image_params p = mpctx->next_frames[n]->params;
 1087|   815k|        if (gm->xy_valid || (gm->wh_valid && (gm->w > 0 || gm->h > 0)))
  ------------------
  |  Branch (1087:13): [True: 0, False: 815k]
  |  Branch (1087:30): [True: 0, False: 815k]
  |  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|   815k|        if (p.crop.x1 == 0 && p.crop.y1 == 0)
  ------------------
  |  Branch (1092:13): [True: 0, False: 815k]
  |  Branch (1092:31): [True: 0, False: 0]
  ------------------
 1093|      0|            return;
 1094|       |
 1095|   815k|        if (!mp_image_crop_valid(&p)) {
  ------------------
  |  Branch (1095:13): [True: 0, False: 815k]
  ------------------
 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|   815k|        mpctx->next_frames[n]->params.crop = p.crop;
 1105|   815k|    }
 1106|   815k|}
video.c:update_avsync_before_frame:
  649|   815k|{
  650|   815k|    struct MPOpts *opts = mpctx->opts;
  651|   815k|    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|   815k|    bool first_frame = mpctx->video_pts == MP_NOPTS_VALUE;
  ------------------
  |  |   39|   815k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  660|   815k|    if (first_frame && mpctx->audio_status == STATUS_PLAYING) {
  ------------------
  |  Branch (660:9): [True: 32.6k, False: 782k]
  |  Branch (660:24): [True: 0, False: 32.6k]
  ------------------
  661|      0|        double apts = written_audio_pts(mpctx);
  662|      0|        double pts = mpctx->next_frames[0]->pts;
  663|      0|        if (apts != MP_NOPTS_VALUE && pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (apts != MP_NOPTS_VALUE && pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (663:13): [True: 0, False: 0]
  |  Branch (663:39): [True: 0, False: 0]
  ------------------
  664|      0|            mpctx->delay = apts + opts->audio_delay - pts;
  665|      0|    }
  666|       |
  667|   815k|    if (mpctx->video_status < STATUS_READY && mpctx->audio_status != STATUS_PLAYING) {
  ------------------
  |  Branch (667:9): [True: 32.6k, False: 782k]
  |  Branch (667:47): [True: 32.6k, False: 0]
  ------------------
  668|  32.6k|        mpctx->time_frame = 0;
  669|   782k|    } else if (mpctx->display_sync_active || vo->opts->video_sync == VS_NONE) {
  ------------------
  |  Branch (669:16): [True: 0, False: 782k]
  |  Branch (669:46): [True: 0, False: 782k]
  ------------------
  670|       |        // don't touch the timing
  671|   782k|    } else if (mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao)) {
  ------------------
  |  Branch (671:16): [True: 0, False: 782k]
  |  Branch (671:57): [True: 0, False: 0]
  ------------------
  672|      0|        double buffered_audio = ao_get_delay(mpctx->ao);
  673|       |
  674|      0|        double predicted = mpctx->delay / mpctx->video_speed +
  675|      0|                           mpctx->time_frame;
  676|      0|        double difference = buffered_audio - predicted;
  677|      0|        MP_STATS(mpctx, "value %f audio-diff", difference);
  ------------------
  |  |   99|      0|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  678|       |
  679|      0|        if (opts->autosync && !first_frame) {
  ------------------
  |  Branch (679:13): [True: 0, False: 0]
  |  Branch (679:31): [True: 0, False: 0]
  ------------------
  680|       |            /* Smooth reported playback position from AO by averaging
  681|       |             * it with the value expected based on previous value and
  682|       |             * time elapsed since then. May help smooth video timing
  683|       |             * with audio output that have inaccurate position reporting.
  684|       |             * This is badly implemented; the behavior of the smoothing
  685|       |             * now undesirably depends on how often this code runs
  686|       |             * (mainly depends on video frame rate). */
  687|      0|            buffered_audio = predicted + difference / opts->autosync;
  688|      0|        }
  689|       |
  690|      0|        mpctx->time_frame = buffered_audio - mpctx->delay / mpctx->video_speed;
  691|   782k|    } 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|   782k|        if (mpctx->time_frame < -0.2 || opts->untimed ||
  ------------------
  |  Branch (699:13): [True: 26, False: 782k]
  |  Branch (699:41): [True: 782k, False: 0]
  ------------------
  700|      0|            (vo->driver->caps & VO_CAP_UNTIMED))
  ------------------
  |  Branch (700:13): [True: 0, False: 0]
  ------------------
  701|   782k|            mpctx->time_frame = 0;
  702|   782k|    }
  703|   815k|}
video.c:calculate_frame_duration:
 1032|   812k|{
 1033|   812k|    struct vo_chain *vo_c = mpctx->vo_chain;
 1034|   812k|    mp_assert(mpctx->num_past_frames >= 1 && mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|   812k|#define mp_assert assert
  ------------------
  |  Branch (1034:5): [True: 812k, False: 0]
  |  Branch (1034:5): [True: 812k, False: 0]
  ------------------
 1035|       |
 1036|   812k|    double demux_duration = vo_c->filter->container_fps > 0
  ------------------
  |  Branch (1036:29): [True: 812k, False: 0]
  ------------------
 1037|   812k|                            ? 1.0 / vo_c->filter->container_fps : -1;
 1038|   812k|    double duration = demux_duration;
 1039|       |
 1040|   812k|    if (mpctx->num_next_frames >= 2) {
  ------------------
  |  Branch (1040:9): [True: 0, False: 812k]
  ------------------
 1041|      0|        double pts0 = mpctx->next_frames[0]->pts;
 1042|      0|        double pts1 = mpctx->next_frames[1]->pts;
 1043|      0|        if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                      if (pts0 != MP_NOPTS_VALUE && pts1 != MP_NOPTS_VALUE && pts1 >= pts0)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (1043:13): [True: 0, False: 0]
  |  Branch (1043:39): [True: 0, False: 0]
  |  Branch (1043:65): [True: 0, False: 0]
  ------------------
 1044|      0|            duration = pts1 - pts0;
 1045|      0|    }
 1046|       |
 1047|       |    // The following code tries to compensate for rounded Matroska timestamps
 1048|       |    // by "unrounding" frame durations, or if not possible, approximating them.
 1049|   812k|    double tolerance = MP_PTS_ROUNDING_TOLERANCE;
  ------------------
  |  |   72|   812k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
 1050|       |
 1051|   812k|    double total = 0;
 1052|   812k|    int num_dur = 0;
 1053|  10.5M|    for (int n = 1; n < mpctx->num_past_frames; n++) {
  ------------------
  |  Branch (1053:21): [True: 9.75M, False: 812k]
  ------------------
 1054|       |        // Eliminate likely outliers using a really dumb heuristic.
 1055|  9.75M|        double dur = mpctx->past_frames[n].duration;
 1056|  9.75M|        if (dur <= 0 || fabs(dur - duration) >= tolerance)
  ------------------
  |  Branch (1056:13): [True: 0, False: 9.75M]
  |  Branch (1056:25): [True: 0, False: 9.75M]
  ------------------
 1057|      0|            break;
 1058|  9.75M|        total += dur;
 1059|  9.75M|        num_dur += 1;
 1060|  9.75M|    }
 1061|   812k|    double approx_duration = num_dur > 0 ? total / num_dur : duration;
  ------------------
  |  Branch (1061:30): [True: 780k, False: 32.5k]
  ------------------
 1062|       |
 1063|       |    // Try if the demuxer frame rate fits - if so, just take it.
 1064|   812k|    if (demux_duration > 0) {
  ------------------
  |  Branch (1064:9): [True: 812k, 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|   812k|        if (fabs(duration - demux_duration) < tolerance &&
  ------------------
  |  Branch (1067:13): [True: 812k, False: 0]
  ------------------
 1068|   812k|            fabs(total - demux_duration * num_dur) < tolerance &&
  ------------------
  |  Branch (1068:13): [True: 812k, False: 0]
  ------------------
 1069|   812k|            (num_dur >= 16 || num_dur >= mpctx->num_past_frames - 4))
  ------------------
  |  Branch (1069:14): [True: 292k, False: 520k]
  |  Branch (1069:31): [True: 520k, False: 0]
  ------------------
 1070|   812k|        {
 1071|   812k|            approx_duration = demux_duration;
 1072|   812k|        }
 1073|   812k|    }
 1074|       |
 1075|   812k|    mpctx->past_frames[0].duration = duration;
 1076|   812k|    mpctx->past_frames[0].approx_duration = approx_duration;
 1077|       |
 1078|   812k|    MP_STATS(mpctx, "value %f frame-duration", MPMAX(0, duration));
  ------------------
  |  |   99|   812k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.62M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 812k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1079|   812k|    MP_STATS(mpctx, "value %f frame-duration-approx", MPMAX(0, approx_duration));
  ------------------
  |  |   99|   812k|#define MP_STATS(obj, ...)      MP_MSG(obj, MSGL_STATS, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  1.62M|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 812k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1080|   812k|}
video.c:shift_frames:
  453|   812k|{
  454|   812k|    if (mpctx->num_next_frames < 1)
  ------------------
  |  Branch (454:9): [True: 0, False: 812k]
  ------------------
  455|      0|        return;
  456|   812k|    talloc_free(mpctx->next_frames[0]);
  ------------------
  |  |   47|   812k|#define talloc_free                     ta_free
  ------------------
  457|   812k|    for (int n = 0; n < mpctx->num_next_frames - 1; n++)
  ------------------
  |  Branch (457:21): [True: 0, False: 812k]
  ------------------
  458|      0|        mpctx->next_frames[n] = mpctx->next_frames[n + 1];
  459|   812k|    mpctx->num_next_frames -= 1;
  460|   812k|}
video.c:schedule_frame:
 1008|   812k|{
 1009|   812k|    handle_display_sync_frame(mpctx, frame);
 1010|       |
 1011|   812k|    if (mpctx->num_past_frames > 1 &&
  ------------------
  |  Branch (1011:9): [True: 780k, False: 32.5k]
  ------------------
 1012|   780k|        ((mpctx->past_frames[1].num_vsyncs >= 0) != mpctx->display_sync_active))
  ------------------
  |  Branch (1012:9): [True: 0, False: 780k]
  ------------------
 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|   812k|    if (!mpctx->display_sync_active) {
  ------------------
  |  Branch (1018:9): [True: 812k, False: 0]
  ------------------
 1019|   812k|        if (mpctx->num_past_frames > 1 && mpctx->past_frames[1].num_vsyncs >= 0) {
  ------------------
  |  Branch (1019:13): [True: 780k, False: 32.5k]
  |  Branch (1019:43): [True: 0, False: 780k]
  ------------------
 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|   812k|        update_av_diff(mpctx, mpctx->time_frame > 0 ?
  ------------------
  |  Branch (1025:31): [True: 0, False: 812k]
  ------------------
 1026|   812k|            mpctx->time_frame * mpctx->video_speed : 0);
 1027|   812k|    }
 1028|   812k|}
video.c:handle_display_sync_frame:
  861|   812k|{
  862|   812k|    struct MPOpts *opts = mpctx->opts;
  863|   812k|    struct vo *vo = mpctx->video_out;
  864|   812k|    int mode = vo->opts->video_sync;
  865|       |
  866|   812k|    bool sync_start = !mpctx->display_sync_active;
  867|   812k|    if (sync_start) {
  ------------------
  |  Branch (867:9): [True: 812k, False: 0]
  ------------------
  868|   812k|        mpctx->display_sync_error = 0.0;
  869|   812k|        mpctx->audio_drift_compensation = 0.0;
  870|   812k|        mpctx->avd_filtered = 0;
  871|   812k|    }
  872|       |
  873|   812k|    mpctx->display_sync_active = false;
  874|       |
  875|   812k|    if (!VS_IS_DISP(mode) || !vo_is_visible(vo) || mpctx->vo_chain->is_sparse ||
  ------------------
  |  |  131|  1.62M|#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE ||       \
  |  |  ------------------
  |  |  |  Branch (131:24): [True: 0, False: 812k]
  |  |  ------------------
  |  |  132|   812k|                       (x) == VS_DISP_RESAMPLE_VDROP || \
  |  |  ------------------
  |  |  |  Branch (132:24): [True: 0, False: 812k]
  |  |  ------------------
  |  |  133|   812k|                       (x) == VS_DISP_RESAMPLE_NONE ||  \
  |  |  ------------------
  |  |  |  Branch (133:24): [True: 0, False: 812k]
  |  |  ------------------
  |  |  134|   812k|                       (x) == VS_DISP_TEMPO ||          \
  |  |  ------------------
  |  |  |  Branch (134:24): [True: 0, False: 812k]
  |  |  ------------------
  |  |  135|   812k|                       (x) == VS_DISP_ADROP ||          \
  |  |  ------------------
  |  |  |  Branch (135:24): [True: 0, False: 812k]
  |  |  ------------------
  |  |  136|   812k|                       (x) == VS_DISP_VDROP ||          \
  |  |  ------------------
  |  |  |  Branch (136:24): [True: 0, False: 812k]
  |  |  ------------------
  |  |  137|  1.62M|                       (x) == VS_DISP_NONE)
  |  |  ------------------
  |  |  |  Branch (137:24): [True: 0, False: 812k]
  |  |  ------------------
  ------------------
  |  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|   812k|        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|   812k|{
  708|   812k|    struct MPOpts *opts = mpctx->opts;
  709|       |
  710|   812k|    mpctx->last_av_difference = 0;
  711|       |
  712|   812k|    if (mpctx->audio_status != STATUS_PLAYING ||
  ------------------
  |  Branch (712:9): [True: 812k, False: 0]
  ------------------
  713|      0|        mpctx->video_status != STATUS_PLAYING)
  ------------------
  |  Branch (713:9): [True: 0, False: 0]
  ------------------
  714|   812k|        return;
  715|       |
  716|      0|    if (mpctx->vo_chain && mpctx->vo_chain->is_sparse)
  ------------------
  |  Branch (716:9): [True: 0, False: 0]
  |  Branch (716:28): [True: 0, False: 0]
  ------------------
  717|      0|        return;
  718|       |
  719|      0|    double a_pos = playing_audio_pts(mpctx);
  720|      0|    if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
                  if (a_pos != MP_NOPTS_VALUE && mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (720:9): [True: 0, False: 0]
  |  Branch (720:36): [True: 0, False: 0]
  ------------------
  721|      0|        mpctx->last_av_difference = a_pos - mpctx->video_pts_unrounded
  722|      0|                                  + opts->audio_delay + offset;
  723|      0|    }
  724|       |
  725|      0|    if (fabs(mpctx->last_av_difference) > 0.5 && !mpctx->drop_message_shown) {
  ------------------
  |  Branch (725:9): [True: 0, False: 0]
  |  Branch (725:50): [True: 0, False: 0]
  ------------------
  726|      0|        MP_WARN(mpctx, "%s", av_desync_help_text);
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  727|       |        mpctx->drop_message_shown = true;
  728|      0|    }
  729|      0|}
video.c:check_framedrop:
  355|   812k|{
  356|   812k|    struct MPOpts *opts = mpctx->opts;
  357|       |    // check for frame-drop:
  358|   812k|    if (mpctx->video_status == STATUS_PLAYING && !mpctx->paused &&
  ------------------
  |  Branch (358:9): [True: 780k, False: 32.5k]
  |  Branch (358:50): [True: 780k, False: 0]
  ------------------
  359|   780k|        mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao) &&
  ------------------
  |  Branch (359:9): [True: 0, False: 780k]
  |  Branch (359:50): [True: 0, False: 0]
  ------------------
  360|      0|        vo_c->track && vo_c->track->dec && (opts->frame_dropping & 2))
  ------------------
  |  Branch (360:9): [True: 0, False: 0]
  |  Branch (360:24): [True: 0, False: 0]
  |  Branch (360:44): [True: 0, False: 0]
  ------------------
  361|      0|    {
  362|      0|        float fps = vo_c->filter->container_fps;
  363|       |        // it's a crappy heuristic; avoid getting upset by incorrect fps
  364|      0|        if (fps <= 20 || fps >= 500)
  ------------------
  |  Branch (364:13): [True: 0, False: 0]
  |  Branch (364:26): [True: 0, False: 0]
  ------------------
  365|      0|            return;
  366|      0|        double frame_time =  1.0 / fps;
  367|       |        // try to drop as many frames as we appear to be behind
  368|      0|        mp_decoder_wrapper_set_frame_drops(vo_c->track->dec,
  369|      0|            MPCLAMP((mpctx->last_av_difference - 0.010) / frame_time, 0, 100));
  ------------------
  |  |   46|      0|#define MPCLAMP(a, min, max) (((a) < (min)) ? (min) : (((a) > (max)) ? (max) : (a)))
  |  |  ------------------
  |  |  |  Branch (46:31): [True: 0, False: 0]
  |  |  |  Branch (46:56): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  370|      0|    }
  371|   812k|}
video.c:handle_new_frame:
  411|   812k|{
  412|   812k|    mp_assert(mpctx->num_next_frames >= 1);
  ------------------
  |  |   41|   812k|#define mp_assert assert
  ------------------
  |  Branch (412:5): [True: 812k, False: 0]
  ------------------
  413|       |
  414|   812k|    double frame_time = 0;
  415|   812k|    double pts = mpctx->next_frames[0]->pts;
  416|   812k|    bool is_sparse = mpctx->vo_chain && mpctx->vo_chain->is_sparse;
  ------------------
  |  Branch (416:22): [True: 812k, False: 0]
  |  Branch (416:41): [True: 0, False: 812k]
  ------------------
  417|       |
  418|   812k|    mpctx->next_pts_unrounded = pts;
  419|   812k|    if (mpctx->video_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (419:9): [True: 780k, False: 32.5k]
  ------------------
  420|   780k|        frame_time = pts - mpctx->video_pts;
  421|   780k|        double tolerance = mpctx->demuxer->ts_resets_possible &&
  ------------------
  |  Branch (421:28): [True: 0, False: 780k]
  ------------------
  422|   780k|                           !is_sparse ? 5 : 1e4;
  ------------------
  |  Branch (422:28): [True: 0, False: 0]
  ------------------
  423|   780k|        if (frame_time <= 0 || frame_time >= tolerance) {
  ------------------
  |  Branch (423:13): [True: 0, False: 780k]
  |  Branch (423:32): [True: 0, False: 780k]
  ------------------
  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|   780k|        } 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|   780k|            double duration = mpctx->past_frames[0].approx_duration;
  437|   780k|            double unrounded = mpctx->video_pts_unrounded + duration;
  438|   780k|            if (duration > 0 && fabs(pts - unrounded) < MP_PTS_ROUNDING_TOLERANCE)
  ------------------
  |  |   72|   780k|#define MP_PTS_ROUNDING_TOLERANCE (0.001 * 3 + 0.0001)
  ------------------
  |  Branch (438:17): [True: 780k, False: 0]
  |  Branch (438:33): [True: 780k, False: 0]
  ------------------
  439|   780k|                mpctx->next_pts_unrounded = unrounded + (pts - unrounded) / 64;
  440|   780k|            frame_time = mpctx->next_pts_unrounded - mpctx->video_pts_unrounded;
  441|   780k|        }
  442|   780k|    }
  443|   812k|    mpctx->time_frame += frame_time / mpctx->video_speed;
  444|   812k|    if (mpctx->ao_chain)
  ------------------
  |  Branch (444:9): [True: 0, False: 812k]
  ------------------
  445|      0|        mpctx->delay -= frame_time;
  446|   812k|    if (mpctx->video_status >= STATUS_PLAYING)
  ------------------
  |  Branch (446:9): [True: 780k, False: 32.5k]
  ------------------
  447|   780k|        adjust_sync(mpctx, mpctx->next_pts_unrounded, frame_time);
  448|   812k|    MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
  ------------------
  |  |   94|   812k|#define MP_TRACE(obj, ...)      MP_MSG(obj, MSGL_TRACE, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|   812k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  449|   812k|}
video.c:adjust_sync:
  383|   780k|{
  384|   780k|    struct MPOpts *opts = mpctx->opts;
  385|       |
  386|   780k|    if (mpctx->audio_status != STATUS_PLAYING)
  ------------------
  |  Branch (386:9): [True: 780k, False: 0]
  ------------------
  387|   780k|        return;
  388|       |
  389|      0|    double a_pts = written_audio_pts(mpctx) + opts->audio_delay - mpctx->delay;
  390|      0|    double av_delay = a_pts - v_pts;
  391|       |
  392|      0|    double change = av_delay * 0.1;
  393|      0|    double factor = fabs(av_delay) < 0.3 ? 0.1 : 0.4;
  ------------------
  |  Branch (393:21): [True: 0, False: 0]
  ------------------
  394|      0|    double max_change = opts->default_max_pts_correction >= 0 ?
  ------------------
  |  Branch (394:25): [True: 0, False: 0]
  ------------------
  395|      0|                        opts->default_max_pts_correction : frame_time * factor;
  396|      0|    if (change < -max_change)
  ------------------
  |  Branch (396:9): [True: 0, False: 0]
  ------------------
  397|      0|        change = -max_change;
  398|      0|    else if (change > max_change)
  ------------------
  |  Branch (398:14): [True: 0, False: 0]
  ------------------
  399|      0|        change = max_change;
  400|      0|    mpctx->delay += change;
  401|      0|    mpctx->total_avsync_change += change;
  402|       |
  403|      0|    if (mpctx->display_sync_active)
  ------------------
  |  Branch (403:9): [True: 0, False: 0]
  ------------------
  404|      0|        mpctx->total_avsync_change = 0;
  405|      0|}

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

stream.c:stream_tell:
  389|   856k|{
  390|   856k|    return s->pos + s->buf_cur - s->buf_end;
  391|   856k|}
demux_lavf.c:stream_tell:
  389|   284k|{
  390|   284k|    return s->pos + s->buf_cur - s->buf_end;
  391|   284k|}
demux_mkv.c:stream_tell:
  389|   108k|{
  390|   108k|    return s->pos + s->buf_cur - s->buf_end;
  391|   108k|}
demux_mkv.c:stream_read_char:
  380|  13.7k|{
  381|  13.7k|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 13.7k, False: 2]
  ------------------
  382|  13.7k|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|  13.7k|        : stream_read_char_fallback(s);
  384|  13.7k|}
demux_playlist.c:stream_read_char:
  380|  67.0k|{
  381|  67.0k|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 63.9k, False: 3.04k]
  ------------------
  382|  67.0k|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|  67.0k|        : stream_read_char_fallback(s);
  384|  67.0k|}
demux_playlist.c:stream_tell:
  389|   187k|{
  390|   187k|    return s->pos + s->buf_cur - s->buf_end;
  391|   187k|}
ebml.c:stream_read_char:
  380|  1.31M|{
  381|  1.31M|    return s->buf_cur < s->buf_end
  ------------------
  |  Branch (381:12): [True: 1.31M, False: 1.19k]
  ------------------
  382|  1.31M|        ? s->buffer[(s->buf_cur++) & s->buffer_mask]
  383|  1.31M|        : stream_read_char_fallback(s);
  384|  1.31M|}
ebml.c:stream_tell:
  389|  43.4k|{
  390|  43.4k|    return s->pos + s->buf_cur - s->buf_end;
  391|  43.4k|}

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

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

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

mp_setup_av_network_options:
  158|  32.5k|{
  159|  32.5k|    void *temp = talloc_new(NULL);
  ------------------
  |  |   40|  32.5k|#define talloc_new                      ta_xnew_context
  |  |  ------------------
  |  |  |  |  122|  32.5k|#define ta_xnew_context(...)            ta_oom_p(ta_new_context(__VA_ARGS__))
  |  |  ------------------
  ------------------
  160|  32.5k|    struct mp_network_opts *opts =
  161|  32.5k|        mp_get_config_group(temp, global, &mp_network_conf);
  162|       |
  163|       |    // HTTP specific options (other protocols ignore them)
  164|  32.5k|    if (opts->useragent)
  ------------------
  |  Branch (164:9): [True: 32.5k, False: 0]
  ------------------
  165|  32.5k|        av_dict_set(dict, "user_agent", opts->useragent, 0);
  166|  32.5k|    if (opts->cookies_enabled) {
  ------------------
  |  Branch (166:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    av_dict_set(dict, "tls_verify", opts->tls_verify ? "1" : "0", 0);
  ------------------
  |  Branch (174:37): [True: 32.5k, False: 0]
  ------------------
  175|  32.5k|    if (opts->tls_ca_file) {
  ------------------
  |  Branch (175:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    if (opts->tls_cert_file) {
  ------------------
  |  Branch (179:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    if (opts->tls_key_file) {
  ------------------
  |  Branch (183:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    char *cust_headers = talloc_strdup(temp, "");
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
  188|  32.5k|    if (opts->referrer) {
  ------------------
  |  Branch (188:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    if (opts->http_header_fields) {
  ------------------
  |  Branch (192:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    if (strlen(cust_headers))
  ------------------
  |  Branch (198:9): [True: 0, False: 32.5k]
  ------------------
  199|      0|        av_dict_set(dict, "headers", cust_headers, 0);
  200|  32.5k|    av_dict_set(dict, "icy", "1", 0);
  201|       |    // So far, every known protocol uses microseconds for this
  202|       |    // Except rtsp.
  203|  32.5k|    if (opts->timeout > 0) {
  ------------------
  |  Branch (203:9): [True: 32.5k, False: 0]
  ------------------
  204|  32.5k|        if (target_fmt && strcmp(target_fmt, "rtsp") == 0) {
  ------------------
  |  Branch (204:13): [True: 32.5k, False: 0]
  |  Branch (204:27): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|        } else {
  207|  32.5k|            char buf[80];
  208|  32.5k|            snprintf(buf, sizeof(buf), "%lld", (long long)(opts->timeout * 1e6));
  209|  32.5k|            av_dict_set(dict, "timeout", buf, 0);
  210|  32.5k|        }
  211|  32.5k|    }
  212|  32.5k|    if (opts->http_proxy && opts->http_proxy[0])
  ------------------
  |  Branch (212:9): [True: 0, False: 32.5k]
  |  Branch (212:29): [True: 0, False: 0]
  ------------------
  213|      0|        av_dict_set(dict, "http_proxy", opts->http_proxy, 0);
  214|       |
  215|  32.5k|    struct stream_lavf_opts *lavf_opts =
  216|  32.5k|        mp_get_config_group(temp, global, &stream_lavf_conf);
  217|  32.5k|    mp_set_avdict(dict, lavf_opts->avopts);
  218|       |
  219|  32.5k|    talloc_free(temp);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  220|  32.5k|}

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

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

sub_destroy:
  148|  6.68k|{
  149|  6.68k|    if (!sub)
  ------------------
  |  Branch (149:9): [True: 0, False: 6.68k]
  ------------------
  150|      0|        return;
  151|  6.68k|    demux_set_stream_wakeup_cb(sub->sh, NULL, NULL);
  152|  6.68k|    if (sub->sd) {
  ------------------
  |  Branch (152:9): [True: 6.66k, False: 25]
  ------------------
  153|  6.66k|        sub_reset(sub);
  154|  6.66k|        sub->sd->driver->uninit(sub->sd);
  155|  6.66k|    }
  156|  6.68k|    talloc_free(sub->sd);
  ------------------
  |  |   47|  6.68k|#define talloc_free                     ta_free
  ------------------
  157|  6.68k|    mp_mutex_destroy(&sub->lock);
  ------------------
  |  |  133|  6.68k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  158|  6.68k|    talloc_free(sub);
  ------------------
  |  |   47|  6.68k|#define talloc_free                     ta_free
  ------------------
  159|  6.68k|}
sub_create:
  197|  6.68k|{
  198|  6.68k|    mp_assert(track->stream && track->stream->type == STREAM_SUB);
  ------------------
  |  |   41|  6.68k|#define mp_assert assert
  ------------------
  |  Branch (198:5): [True: 6.68k, False: 0]
  |  Branch (198:5): [True: 6.68k, False: 0]
  ------------------
  199|       |
  200|  6.68k|    struct dec_sub *sub = talloc(NULL, struct dec_sub);
  ------------------
  |  |   26|  6.68k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  6.68k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  6.68k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|  6.68k|    *sub = (struct dec_sub){
  202|  6.68k|        .log = mp_log_new(sub, global->log, "sub"),
  203|  6.68k|        .global = global,
  204|  6.68k|        .packet_pool = demux_packet_pool_get(global),
  205|  6.68k|        .opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_sub_opts),
  206|  6.68k|        .shared_opts_cache = m_config_cache_alloc(sub, global, &mp_subtitle_shared_sub_opts),
  207|  6.68k|        .sh = track->stream,
  208|  6.68k|        .codec = track->stream->codec,
  209|  6.68k|        .lang = track->lang,
  210|  6.68k|        .attachments = talloc_steal(sub, attachments),
  ------------------
  |  |   38|  6.68k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  6.68k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  211|  6.68k|        .play_dir = 1,
  212|  6.68k|        .order = order,
  213|  6.68k|        .last_pkt_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  6.68k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  214|  6.68k|        .last_vo_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  6.68k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  215|  6.68k|        .start = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  6.68k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  216|  6.68k|        .end = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  6.68k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  217|  6.68k|    };
  218|  6.68k|    sub->opts = sub->opts_cache->opts;
  219|  6.68k|    sub->shared_opts = sub->shared_opts_cache->opts;
  220|  6.68k|    mp_mutex_init(&sub->lock);
  221|       |
  222|  6.68k|    sub->sd = init_decoder(sub);
  223|  6.68k|    if (sub->sd) {
  ------------------
  |  Branch (223:9): [True: 6.66k, False: 25]
  ------------------
  224|  6.66k|        update_subtitle_speed(sub);
  225|  6.66k|        return sub;
  226|  6.66k|    }
  227|       |
  228|     25|    sub_destroy(sub);
  229|       |    return NULL;
  230|  6.68k|}
sub_can_preload:
  262|   179k|{
  263|   179k|    bool r;
  264|   179k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   179k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  265|   179k|    r = sub->sd->driver->accept_packets_in_advance && !sub->preload_attempted;
  ------------------
  |  Branch (265:9): [True: 179k, False: 0]
  |  Branch (265:55): [True: 2.34k, False: 176k]
  ------------------
  266|   179k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   179k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  267|   179k|    return r;
  268|   179k|}
sub_preload:
  271|  2.34k|{
  272|  2.34k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  2.34k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  273|       |
  274|  2.34k|    struct mp_dispatch_queue *demux_waiter = mp_dispatch_create(NULL);
  275|  2.34k|    demux_set_stream_wakeup_cb(sub->sh, wakeup_demux, demux_waiter);
  276|       |
  277|  2.34k|    sub->preload_attempted = true;
  278|       |
  279|  12.4k|    for (;;) {
  280|  12.4k|        struct demux_packet *pkt = NULL;
  281|  12.4k|        int r = demux_read_packet_async(sub->sh, &pkt);
  282|  12.4k|        if (r == 0) {
  ------------------
  |  Branch (282:13): [True: 0, False: 12.4k]
  ------------------
  283|      0|            mp_dispatch_queue_process(demux_waiter, INFINITY);
  284|      0|            continue;
  285|      0|        }
  286|  12.4k|        if (!pkt)
  ------------------
  |  Branch (286:13): [True: 2.34k, False: 10.0k]
  ------------------
  287|  2.34k|            break;
  288|  10.0k|        sub->sd->driver->decode(sub->sd, pkt);
  289|  10.0k|        MP_TARRAY_APPEND(sub, sub->cached_pkts, sub->num_cached_pkts, pkt);
  ------------------
  |  |  105|  10.0k|    do {                                            \
  |  |  106|  10.0k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  10.0k|    do {                                            \
  |  |  |  |   97|  10.0k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  10.0k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  10.0k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  10.0k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 1.61k, False: 8.45k]
  |  |  |  |  ------------------
  |  |  |  |   99|  10.0k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  1.61k|    do {                                                        \
  |  |  |  |  |  |   89|  1.61k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  1.61k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.61k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.61k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.61k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  1.61k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  1.61k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 1.61k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  10.0k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 10.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  10.0k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  10.0k|        (idxvar)++;                                 \
  |  |  109|  10.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 10.0k]
  |  |  ------------------
  ------------------
  290|  10.0k|    }
  291|       |
  292|  2.34k|    demux_set_stream_wakeup_cb(sub->sh, NULL, NULL);
  293|  2.34k|    talloc_free(demux_waiter);
  ------------------
  |  |   47|  2.34k|#define talloc_free                     ta_free
  ------------------
  294|       |
  295|  2.34k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  2.34k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  296|  2.34k|}
sub_read_packets:
  347|   512k|{
  348|   512k|    *packets_read = true;
  349|   512k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   512k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  350|   512k|    video_pts = pts_to_subtitle(sub, video_pts);
  351|   565k|    while (1) {
  ------------------
  |  Branch (351:12): [True: 565k, Folded]
  ------------------
  352|   565k|        bool read_more = true;
  353|   565k|        if (sub->sd->driver->accepts_packet)
  ------------------
  |  Branch (353:13): [True: 16.1k, False: 549k]
  ------------------
  354|  16.1k|            read_more = sub->sd->driver->accepts_packet(sub->sd, video_pts);
  355|       |
  356|   565k|        if (!read_more)
  ------------------
  |  Branch (356:13): [True: 0, False: 565k]
  ------------------
  357|      0|            break;
  358|       |
  359|   565k|        if (sub->new_segment && sub->new_segment->start < video_pts) {
  ------------------
  |  Branch (359:13): [True: 0, False: 565k]
  |  Branch (359:33): [True: 0, False: 0]
  ------------------
  360|      0|            sub->last_vo_pts = video_pts;
  361|      0|            update_segment(sub);
  362|      0|        }
  363|       |
  364|   565k|        if (sub->new_segment)
  ------------------
  |  Branch (364:13): [True: 0, False: 565k]
  ------------------
  365|      0|            break;
  366|       |
  367|       |        // (Use this mechanism only if sub_delay matters to avoid corner cases.)
  368|   565k|        double delay = sub->order < 0 ? 0.0 : sub->shared_opts->sub_delay[sub->order];
  ------------------
  |  Branch (368:24): [True: 0, False: 565k]
  ------------------
  369|   565k|        double min_pts = delay < 0 || force ? video_pts : MP_NOPTS_VALUE;
  ------------------
  |  |   39|   565k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (369:26): [True: 0, False: 565k]
  |  Branch (369:39): [True: 0, False: 565k]
  ------------------
  370|       |
  371|   565k|        struct demux_packet *pkt;
  372|   565k|        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|   565k|        if (st <= 0) {
  ------------------
  |  Branch (378:13): [True: 512k, False: 52.9k]
  ------------------
  379|   512k|            *packets_read = st < 0 || (sub->last_pkt_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|  19.6k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (379:29): [True: 502k, False: 9.82k]
  |  Branch (379:40): [True: 1.45k, False: 8.37k]
  ------------------
  380|  1.45k|                                       sub->last_pkt_pts > video_pts);
  ------------------
  |  Branch (380:40): [True: 1.40k, False: 41]
  ------------------
  381|   512k|            break;
  382|   512k|        }
  383|       |
  384|  52.9k|        if (sub->recorder_sink)
  ------------------
  |  Branch (384:13): [True: 0, False: 52.9k]
  ------------------
  385|      0|            mp_recorder_feed_packet(sub->recorder_sink, pkt);
  386|       |
  387|  52.9k|        sub->last_pkt_pts = pkt->pts;
  388|  52.9k|        MP_TARRAY_APPEND(sub, sub->cached_pkts, sub->num_cached_pkts, pkt);
  ------------------
  |  |  105|  52.9k|    do {                                            \
  |  |  106|  52.9k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  52.9k|    do {                                            \
  |  |  |  |   97|  52.9k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  52.9k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  52.9k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  52.9k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6.31k, False: 46.6k]
  |  |  |  |  ------------------
  |  |  |  |   99|  52.9k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  6.31k|    do {                                                        \
  |  |  |  |  |  |   89|  6.31k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  6.31k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  6.31k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  6.31k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  6.31k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  6.31k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  6.31k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6.31k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  52.9k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 52.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  52.9k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  52.9k|        (idxvar)++;                                 \
  |  |  109|  52.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 52.9k]
  |  |  ------------------
  ------------------
  389|       |
  390|  52.9k|        if (is_new_segment(sub, pkt)) {
  ------------------
  |  Branch (390:13): [True: 0, False: 52.9k]
  ------------------
  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|  52.9k|        if (!(sub->preload_attempted && sub->sd->preload_ok))
  ------------------
  |  Branch (397:15): [True: 0, False: 52.9k]
  |  Branch (397:41): [True: 0, False: 0]
  ------------------
  398|  52.9k|            sub->sd->driver->decode(sub->sd, pkt);
  399|  52.9k|    }
  400|   512k|    if (sub->cached_pkts && sub->num_cached_pkts) {
  ------------------
  |  Branch (400:9): [True: 381k, False: 130k]
  |  Branch (400:29): [True: 381k, False: 0]
  ------------------
  401|   381k|        bool visible = is_packet_visible(sub->cached_pkts[sub->cached_pkt_pos], video_pts);
  402|   381k|        *sub_updated = update_pkt_cache(sub, video_pts) || sub->sub_visible != visible;
  ------------------
  |  Branch (402:24): [True: 16.9k, False: 364k]
  |  Branch (402:60): [True: 5.53k, False: 359k]
  ------------------
  403|   381k|        sub->sub_visible = visible;
  404|   381k|    }
  405|   512k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   512k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  406|   512k|}
sub_get_bitmaps:
  424|   166k|{
  425|   166k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   166k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  426|       |
  427|   166k|    pts = pts_to_subtitle(sub, pts);
  428|       |
  429|   166k|    sub->last_vo_pts = pts;
  430|   166k|    update_segment(sub);
  431|       |
  432|   166k|    struct sub_bitmaps *res = NULL;
  433|       |
  434|   166k|    if (!(sub->end != MP_NOPTS_VALUE && pts >= sub->end) &&
  ------------------
  |  |   39|   333k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (434:11): [True: 0, False: 166k]
  |  Branch (434:41): [True: 0, False: 0]
  ------------------
  435|   166k|        sub->sd->driver->get_bitmaps)
  ------------------
  |  Branch (435:9): [True: 166k, False: 0]
  ------------------
  436|   166k|        res = sub->sd->driver->get_bitmaps(sub->sd, dim, format, pts);
  437|       |
  438|   166k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   166k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  439|   166k|    return res;
  440|   166k|}
sub_reset:
  491|  13.3k|{
  492|  13.3k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  13.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  493|  13.3k|    if (sub->sd->driver->reset)
  ------------------
  |  Branch (493:9): [True: 13.3k, False: 0]
  ------------------
  494|  13.3k|        sub->sd->driver->reset(sub->sd);
  495|  13.3k|    sub->last_pkt_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  13.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  496|  13.3k|    sub->last_vo_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  13.3k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  497|  13.3k|    destroy_cached_pkts(sub);
  498|  13.3k|    demux_packet_pool_push(sub->packet_pool, sub->new_segment);
  499|  13.3k|    sub->new_segment = NULL;
  500|  13.3k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  13.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  501|  13.3k|}
sub_select:
  504|  13.3k|{
  505|  13.3k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  13.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  506|  13.3k|    if (sub->sd->driver->select)
  ------------------
  |  Branch (506:9): [True: 12.9k, False: 414]
  ------------------
  507|  12.9k|        sub->sd->driver->select(sub->sd, selected);
  508|  13.3k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  13.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  509|  13.3k|}
sub_control:
  512|  1.01M|{
  513|  1.01M|    int r = CONTROL_UNKNOWN;
  ------------------
  |  |   98|  1.01M|#define CONTROL_UNKNOWN -1
  ------------------
  514|  1.01M|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  1.01M|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  515|  1.01M|    bool propagate = false;
  516|  1.01M|    switch (cmd) {
  517|  6.66k|    case SD_CTRL_SET_VIDEO_DEF_FPS:
  ------------------
  |  Branch (517:5): [True: 6.66k, False: 1.01M]
  ------------------
  518|  6.66k|        sub->video_fps = *(double *)arg;
  519|  6.66k|        update_subtitle_speed(sub);
  520|  6.66k|        break;
  521|      0|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (521:5): [True: 0, False: 1.01M]
  ------------------
  522|      0|        double *a = arg;
  523|      0|        double arg2[2] = {a[0], a[1]};
  524|      0|        arg2[0] = pts_to_subtitle(sub, arg2[0]);
  525|      0|        if (sub->sd->driver->control)
  ------------------
  |  Branch (525:13): [True: 0, False: 0]
  ------------------
  526|      0|            r = sub->sd->driver->control(sub->sd, cmd, arg2);
  527|      0|        if (r == CONTROL_OK)
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  |  Branch (527:13): [True: 0, False: 0]
  ------------------
  528|      0|            a[0] = pts_from_subtitle(sub, arg2[0]);
  529|      0|        break;
  530|      0|    }
  531|      0|    case SD_CTRL_UPDATE_OPTS: {
  ------------------
  |  Branch (531:5): [True: 0, False: 1.01M]
  ------------------
  532|      0|        uint64_t flags = *(uint64_t *)arg;
  533|      0|        if (m_config_cache_update(sub->opts_cache))
  ------------------
  |  Branch (533:13): [True: 0, False: 0]
  ------------------
  534|      0|            update_subtitle_speed(sub);
  535|      0|        m_config_cache_update(sub->shared_opts_cache);
  536|      0|        propagate = true;
  537|      0|        if (flags & UPDATE_SUB_HARD) {
  ------------------
  |  |  455|      0|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (537:13): [True: 0, False: 0]
  ------------------
  538|       |            // forget about the previous preload because
  539|       |            // UPDATE_SUB_HARD will cause a sub reinit
  540|       |            // that clears all preloaded sub packets
  541|      0|            sub->preload_attempted = false;
  542|      0|        }
  543|      0|        break;
  544|      0|    }
  545|  1.01M|    default:
  ------------------
  |  Branch (545:5): [True: 1.01M, False: 6.66k]
  ------------------
  546|  1.01M|        propagate = true;
  547|  1.01M|    }
  548|  1.01M|    if (propagate && sub->sd->driver->control)
  ------------------
  |  Branch (548:9): [True: 1.01M, False: 6.66k]
  |  Branch (548:22): [True: 1.01M, False: 0]
  ------------------
  549|  1.01M|        r = sub->sd->driver->control(sub->sd, cmd, arg);
  550|  1.01M|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  1.01M|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  551|  1.01M|    return r;
  552|  1.01M|}
sub_set_play_dir:
  562|  6.66k|{
  563|  6.66k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|  6.66k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  564|  6.66k|    sub->play_dir = dir;
  565|  6.66k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|  6.66k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  566|  6.66k|}
sub_is_primary_visible:
  569|   166k|{
  570|   166k|    mp_mutex_lock(&sub->lock);
  ------------------
  |  |  134|   166k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  571|   166k|    bool ret = sub->shared_opts->sub_visibility[0];
  572|   166k|    mp_mutex_unlock(&sub->lock);
  ------------------
  |  |  136|   166k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  573|   166k|    return ret;
  574|   166k|}
dec_sub.c:init_decoder:
  162|  6.68k|{
  163|  13.1k|    for (int n = 0; sd_list[n]; n++) {
  ------------------
  |  Branch (163:21): [True: 13.1k, False: 25]
  ------------------
  164|  13.1k|        const struct sd_functions *driver = sd_list[n];
  165|  13.1k|        struct sd *sd = talloc(NULL, struct sd);
  ------------------
  |  |   26|  13.1k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|  13.1k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  13.1k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|  13.1k|        *sd = (struct sd){
  167|  13.1k|            .global = sub->global,
  168|  13.1k|            .log = mp_log_new(sd, sub->log, driver->name),
  169|  13.1k|            .opts = sub->opts,
  170|  13.1k|            .shared_opts = sub->shared_opts,
  171|  13.1k|            .driver = driver,
  172|  13.1k|            .order = sub->order,
  173|  13.1k|            .attachments = sub->attachments,
  174|  13.1k|            .codec = sub->codec,
  175|  13.1k|            .lang = sub->lang,
  176|  13.1k|            .preload_ok = true,
  177|  13.1k|        };
  178|       |
  179|  13.1k|        if (sd->driver->init(sd) >= 0)
  ------------------
  |  Branch (179:13): [True: 6.66k, False: 6.50k]
  ------------------
  180|  6.66k|            return sd;
  181|       |
  182|  6.50k|        talloc_free(sd);
  ------------------
  |  |   47|  6.50k|#define talloc_free                     ta_free
  ------------------
  183|  6.50k|    }
  184|       |
  185|     25|    MP_ERR(sub, "Could not find subtitle decoder for format '%s'.\n",
  ------------------
  |  |   89|     25|#define MP_ERR(obj, ...)        MP_MSG(obj, MSGL_ERR, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|     25|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  186|     25|           sub->codec->codec);
  187|       |    return NULL;
  188|  6.68k|}
dec_sub.c:update_subtitle_speed:
   90|  13.3k|{
   91|  13.3k|    struct mp_subtitle_opts *opts = sub->opts;
   92|  13.3k|    sub->sub_speed = 1.0;
   93|       |
   94|  13.3k|    if (sub->video_fps > 0 && sub->codec->frame_based > 0) {
  ------------------
  |  Branch (94:9): [True: 6.66k, False: 6.66k]
  |  Branch (94:31): [True: 0, False: 6.66k]
  ------------------
   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|  13.3k|    if (opts->sub_fps && sub->video_fps)
  ------------------
  |  Branch (100:9): [True: 0, False: 13.3k]
  |  Branch (100:26): [True: 0, False: 0]
  ------------------
  101|      0|        sub->sub_speed *= opts->sub_fps / sub->video_fps;
  102|       |
  103|  13.3k|    sub->sub_speed *= opts->sub_speed;
  104|  13.3k|}
dec_sub.c:wakeup_demux:
  130|  12.4k|{
  131|  12.4k|    struct mp_dispatch_queue *q = ctx;
  132|  12.4k|    mp_dispatch_interrupt(q);
  133|  12.4k|}
dec_sub.c:pts_to_subtitle:
  108|   678k|{
  109|   678k|    struct mp_subtitle_shared_opts *opts = sub->shared_opts;
  110|   678k|    double delay = sub->order < 0 ? 0.0 : opts->sub_delay[sub->order];
  ------------------
  |  Branch (110:20): [True: 0, False: 678k]
  ------------------
  111|       |
  112|   678k|    if (pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   678k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (112:9): [True: 667k, False: 11.3k]
  ------------------
  113|   667k|        pts = (pts * sub->play_dir - delay) / sub->sub_speed;
  114|       |
  115|   678k|    return pts;
  116|   678k|}
dec_sub.c:update_segment:
  234|   166k|{
  235|   166k|    if (sub->new_segment && sub->last_vo_pts != MP_NOPTS_VALUE &&
  ------------------
  |  |   39|   166k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (235:9): [True: 0, False: 166k]
  |  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|   166k|}
dec_sub.c:is_new_segment:
  299|  52.9k|{
  300|  52.9k|    return p->segmented &&
  ------------------
  |  Branch (300:12): [True: 0, False: 52.9k]
  ------------------
  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|  52.9k|}
dec_sub.c:is_packet_visible:
  305|   381k|{
  306|   381k|    return p && p->pts <= video_pts && (video_pts <= p->pts + p->sub_duration ||
  ------------------
  |  Branch (306:12): [True: 381k, False: 0]
  |  Branch (306:17): [True: 240k, False: 141k]
  |  Branch (306:41): [True: 54.8k, False: 186k]
  ------------------
  307|   186k|           p->sub_duration < 0);
  ------------------
  |  Branch (307:12): [True: 156k, False: 29.0k]
  ------------------
  308|   381k|}
dec_sub.c:update_pkt_cache:
  311|   381k|{
  312|   381k|    if (!sub->cached_pkts[sub->cached_pkt_pos])
  ------------------
  |  Branch (312:9): [True: 0, False: 381k]
  ------------------
  313|      0|        return false;
  314|       |
  315|   381k|    struct demux_packet *pkt = sub->cached_pkts[sub->cached_pkt_pos];
  316|   381k|    struct demux_packet *next_pkt = sub->cached_pkt_pos + 1 < sub->num_cached_pkts ?
  ------------------
  |  Branch (316:37): [True: 91.4k, False: 290k]
  ------------------
  317|   381k|                                    sub->cached_pkts[sub->cached_pkt_pos + 1] : NULL;
  318|   381k|    if (!pkt)
  ------------------
  |  Branch (318:9): [True: 0, False: 381k]
  ------------------
  319|      0|        return false;
  320|       |
  321|   381k|    double pts = video_pts + sub->shared_opts->sub_delay[sub->order];
  322|   381k|    double next_pts = next_pkt ? next_pkt->pts : INT_MAX;
  ------------------
  |  Branch (322:23): [True: 91.4k, False: 290k]
  ------------------
  323|   381k|    double end_pts = pkt->sub_duration >= 0 ? pkt->pts + pkt->sub_duration : INT_MAX;
  ------------------
  |  Branch (323:22): [True: 116k, False: 265k]
  ------------------
  324|       |
  325|   381k|    if (next_pts < pts || end_pts < pts) {
  ------------------
  |  Branch (325:9): [True: 16.9k, False: 364k]
  |  Branch (325:27): [True: 13.2k, False: 351k]
  ------------------
  326|  30.1k|        if (sub->cached_pkt_pos + 1 < sub->num_cached_pkts) {
  ------------------
  |  Branch (326:13): [True: 16.9k, False: 13.2k]
  ------------------
  327|  16.9k|            TA_FREEP(&sub->cached_pkts[sub->cached_pkt_pos]);
  ------------------
  |  |   81|  16.9k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  16.9k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 16.9k]
  |  |  ------------------
  ------------------
  328|  16.9k|            pkt = NULL;
  329|  16.9k|            sub->cached_pkt_pos++;
  330|  16.9k|        }
  331|  30.1k|        if (next_pts < pts)
  ------------------
  |  Branch (331:13): [True: 16.9k, False: 13.2k]
  ------------------
  332|  16.9k|            return true;
  333|  30.1k|    }
  334|       |
  335|   364k|    if (pkt && pkt->animated == 1)
  ------------------
  |  Branch (335:9): [True: 364k, False: 25]
  |  Branch (335:16): [True: 0, False: 364k]
  ------------------
  336|      0|        return true;
  337|       |
  338|   364k|    return false;
  339|   364k|}
dec_sub.c:destroy_cached_pkts:
  136|  13.3k|{
  137|  13.3k|    int index = 0;
  138|  76.3k|    while (index < sub->num_cached_pkts) {
  ------------------
  |  Branch (138:12): [True: 63.0k, False: 13.3k]
  ------------------
  139|  63.0k|        demux_packet_pool_push(sub->packet_pool, sub->cached_pkts[index]);
  140|       |        sub->cached_pkts[index] = NULL;
  141|  63.0k|        ++index;
  142|  63.0k|    }
  143|  13.3k|    sub->cached_pkt_pos = 0;
  144|  13.3k|    sub->num_cached_pkts = 0;
  145|  13.3k|}

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

filter_sdh.c:sdh_init:
  438|  6.45k|{
  439|  6.45k|    if (strcmp(ft->codec, "ass") != 0)
  ------------------
  |  Branch (439:9): [True: 0, False: 6.45k]
  ------------------
  440|      0|        return false;
  441|       |
  442|  6.45k|    if (!ft->opts->sub_filter_SDH)
  ------------------
  |  Branch (442:9): [True: 0, False: 6.45k]
  ------------------
  443|      0|        return false;
  444|       |
  445|  6.45k|    if (!ft->event_format) {
  ------------------
  |  Branch (445:9): [True: 0, False: 6.45k]
  ------------------
  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|  6.45k|    struct priv *p = talloc_zero(ft, struct priv);
  ------------------
  |  |   27|  6.45k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  6.45k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  6.45k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  451|  6.45k|    ft->priv = p;
  452|  6.45k|    p->offset = sd_ass_fmt_offset(ft->event_format);
  453|       |    return true;
  454|  6.45k|}
filter_sdh.c:sdh_filter:
  458|  62.4k|{
  459|  62.4k|    struct priv *p = ft->priv;
  460|  62.4k|    bstr text = sd_ass_pkt_text(ft, pkt, p->offset);
  461|  62.4k|    if (!text.start || !text.len)
  ------------------
  |  Branch (461:9): [True: 0, False: 62.4k]
  |  Branch (461:24): [True: 11.1k, False: 51.2k]
  ------------------
  462|  11.1k|        return pkt;  // we don't touch it
  463|       |
  464|  51.2k|    bstr line = filter_SDH(ft, text);
  465|  51.2k|    if (!line.start)
  ------------------
  |  Branch (465:9): [True: 2.21k, False: 49.0k]
  ------------------
  466|  2.21k|        return NULL;  // all text removed by filtering
  467|       |
  468|  49.0k|    struct demux_packet *npkt = pkt;  // unmodified, no need to allocate new packet
  469|       |    // the filter only removes bytes, so an unchanged length means an unchanged text
  470|  49.0k|    if (line.len != text.len) {
  ------------------
  |  Branch (470:9): [True: 2.54k, False: 46.5k]
  ------------------
  471|       |        // the event fields before the text are kept as they are
  472|  2.54k|        size_t hlen = text.start - pkt->buffer;
  473|  2.54k|        npkt = new_demux_packet(ft->packet_pool, hlen + line.len);
  474|  2.54k|        if (npkt) {
  ------------------
  |  Branch (474:13): [True: 2.54k, False: 0]
  ------------------
  475|  2.54k|            memcpy(npkt->buffer, pkt->buffer, hlen);
  476|  2.54k|            memcpy(npkt->buffer + hlen, line.start, line.len);
  477|  2.54k|            demux_packet_copy_attribs(npkt, pkt);
  478|  2.54k|        }
  479|  2.54k|    }
  480|  49.0k|    talloc_free(line.start);
  ------------------
  |  |   47|  49.0k|#define talloc_free                     ta_free
  ------------------
  481|  49.0k|    return npkt;
  482|  51.2k|}
filter_sdh.c:filter_SDH:
  345|  51.2k|{
  346|  51.2k|    struct buffer writebuf;
  347|  51.2k|    struct buffer *buf = &writebuf;
  348|  51.2k|    init_buf(buf, text.len + 1); // with room for terminating '\0'
  349|       |
  350|       |    // rp is the (null-terminated) remaining text
  351|  51.2k|    char *ass = bstrdup0(NULL, text), *rp = ass;
  352|       |
  353|  51.2k|    bool contains_text = false;  // true if non SDH text was found
  354|  51.2k|    bool line_with_text = false; // if last line contained text
  355|  51.2k|    size_t wp_line_start = 0; // write pos to start of last line
  356|  51.2k|    size_t wp_line_end   = 0; // write pos to end of previous line with text (\N)
  357|       |
  358|       |    // go through the lines in the text
  359|       |    // they are separated by \N
  360|   112k|    while (*rp) {
  ------------------
  |  Branch (360:12): [True: 61.2k, False: 51.2k]
  ------------------
  361|  61.2k|        line_with_text = false;
  362|  61.2k|        wp_line_start = buf->pos;
  363|       |
  364|       |        // skip any speaker label
  365|  61.2k|        skip_speaker_label(sd, &rp, buf);
  366|       |
  367|       |        // go through the rest of the line looking for SDH in () or []
  368|  1.50M|        while (*rp && !(rp[0] == '\\' && rp[1] == 'N')) {
  ------------------
  |  Branch (368:16): [True: 1.45M, False: 51.2k]
  |  Branch (368:25): [True: 28.9k, False: 1.42M]
  |  Branch (368:42): [True: 9.99k, False: 18.9k]
  ------------------
  369|  1.44M|            copy_ass(sd, &rp, buf);
  370|  1.44M|            char left[5] = {0};
  371|  1.44M|            char **enclosures = sd->opts->sub_filter_SDH_enclosures;
  372|  1.44M|            int index = matching_enclosure(enclosures, rp);
  373|  1.44M|            if (index > -1) {
  ------------------
  |  Branch (373:17): [True: 40.5k, False: 1.40M]
  ------------------
  374|  40.5k|                int bytes = get_char_bytes(rp);
  375|  81.0k|                for (int i = 0; i < bytes; i++)
  ------------------
  |  Branch (375:33): [True: 40.5k, False: 40.5k]
  ------------------
  376|  40.5k|                    left[i] = rp[i];
  377|  40.5k|            }
  378|  1.44M|            if (left[0]) {
  ------------------
  |  Branch (378:17): [True: 40.5k, False: 1.40M]
  ------------------
  379|       |                // Skip left character
  380|  40.5k|                char *right = enclosures[index] + get_char_bytes(enclosures[index]);
  381|  40.5k|                if (!skip_enclosed(sd, &rp, buf, left, right)) {
  ------------------
  |  Branch (381:21): [True: 33.1k, False: 7.36k]
  ------------------
  382|  33.1k|                    append(sd, buf, rp[0]);
  383|  33.1k|                    rp++;
  384|  33.1k|                    line_with_text =  true;
  385|  33.1k|                }
  386|  1.40M|            } else if (*rp && rp[0] != '\\') {
  ------------------
  |  Branch (386:24): [True: 1.40M, False: 4.08k]
  |  Branch (386:31): [True: 1.38M, False: 20.3k]
  ------------------
  387|  1.38M|                if ((rp[0] > 32 && rp[0] < 127 && rp[0] != '-') ||
  ------------------
  |  Branch (387:22): [True: 711k, False: 669k]
  |  Branch (387:36): [True: 701k, False: 10.2k]
  |  Branch (387:51): [True: 695k, False: 5.57k]
  ------------------
  388|   685k|                    (unsigned char)rp[0] >= 0xC0)
  ------------------
  |  Branch (388:21): [True: 287k, False: 398k]
  ------------------
  389|   983k|                {
  390|   983k|                    line_with_text =  true;
  391|   983k|                }
  392|  1.38M|                append(sd, buf, rp[0]);
  393|  1.38M|                rp++;
  394|  1.38M|            } else if (rp[0] == '\\' && rp[1] != 'N') {
  ------------------
  |  Branch (394:24): [True: 20.3k, False: 4.08k]
  |  Branch (394:41): [True: 19.7k, False: 572]
  ------------------
  395|  19.7k|                append(sd, buf, rp[0]);
  396|  19.7k|                rp++;
  397|  19.7k|            }
  398|  1.44M|        }
  399|       |        // either end of data or ASS line end defined by separating \N
  400|  61.2k|        if (*rp) {
  ------------------
  |  Branch (400:13): [True: 9.99k, False: 51.2k]
  ------------------
  401|       |            // ASS line end
  402|  9.99k|            if (line_with_text) {
  ------------------
  |  Branch (402:17): [True: 4.67k, False: 5.32k]
  ------------------
  403|  4.67k|                contains_text = true;
  404|  4.67k|                wp_line_end = buf->pos;
  405|  4.67k|                append(sd, buf, rp[0]); // copy backslash
  406|  4.67k|                append(sd, buf, rp[1]); // copy N
  407|  4.67k|                rp += 2; // move read pointer past \N
  408|  5.32k|            } else {
  409|       |                // no text in line, remove leading hyphen and spaces
  410|  5.32k|                remove_leading_hyphen_space(sd, wp_line_start, buf);
  411|       |                // and join with next line
  412|  5.32k|                rp += 2; // move read pointer past \N
  413|  5.32k|            }
  414|  9.99k|        }
  415|  61.2k|    }
  416|       |    // if no normal text in last line - remove last line
  417|       |    // by moving write pointer to start of last line
  418|  51.2k|    if (!line_with_text) {
  ------------------
  |  Branch (418:9): [True: 2.24k, False: 49.0k]
  ------------------
  419|  2.24k|        buf->pos = wp_line_end;
  420|  49.0k|    } else {
  421|  49.0k|        contains_text = true;
  422|  49.0k|    }
  423|  51.2k|    talloc_free(ass);
  ------------------
  |  |   47|  51.2k|#define talloc_free                     ta_free
  ------------------
  424|       |
  425|  51.2k|    if (!contains_text) {
  ------------------
  |  Branch (425:9): [True: 2.21k, False: 49.0k]
  ------------------
  426|       |        // all text removed by filtering
  427|  2.21k|        talloc_free(buf->string);
  ------------------
  |  |   47|  2.21k|#define talloc_free                     ta_free
  ------------------
  428|  2.21k|        return (bstr){0};
  429|  2.21k|    }
  430|  49.0k|    return (bstr){(unsigned char *)buf->string, buf->pos};
  431|  51.2k|}
filter_sdh.c:init_buf:
   42|  51.2k|{
   43|  51.2k|    buf->string = talloc_size(NULL, length);
  ------------------
  |  |   43|  51.2k|#define talloc_size                     ta_xalloc_size
  |  |  ------------------
  |  |  |  |  120|  51.2k|#define ta_xalloc_size(...)             ta_oom_p(ta_alloc_size(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  153|  51.2k|#define ta_alloc_size(...)      ta_dbg_set_loc(ta_alloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   43|  51.2k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   38|  51.2k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   37|  51.2k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   44|  51.2k|    buf->pos = 0;
   45|  51.2k|    buf->length = length;
   46|  51.2k|}
filter_sdh.c:skip_speaker_label:
  147|  61.2k|{
  148|  61.2k|    int filter_harder = sd->opts->sub_filter_SDH_harder;
  149|  61.2k|    char *rp = *rpp;
  150|  61.2k|    size_t old_pos = buf->pos;
  151|       |
  152|  61.2k|    copy_ass(sd, &rp, buf);
  153|       |    // copy any leading "- "
  154|  61.2k|    if (rp[0] == '-') {
  ------------------
  |  Branch (154:9): [True: 564, False: 60.7k]
  ------------------
  155|    564|        append(sd, buf, rp[0]);
  156|    564|        rp++;
  157|    564|    }
  158|  61.2k|    copy_ass(sd, &rp, buf);
  159|  62.0k|    while (rp[0] == ' ') {
  ------------------
  |  Branch (159:12): [True: 762, False: 61.2k]
  ------------------
  160|    762|        append(sd, buf, rp[0]);
  161|    762|        rp++;
  162|    762|        copy_ass(sd, &rp, buf);
  163|    762|    }
  164|       |    // skip past valid data searching for :
  165|  92.0k|    while (*rp && rp[0] != ':') {
  ------------------
  |  Branch (165:12): [True: 88.0k, False: 4.04k]
  |  Branch (165:19): [True: 87.0k, False: 982]
  ------------------
  166|  87.0k|        if (rp[0] == '{') {
  ------------------
  |  Branch (166:13): [True: 988, False: 86.0k]
  ------------------
  167|    988|            copy_ass(sd, &rp, buf);
  168|  86.0k|        } else if (rp[0] == '[') {
  ------------------
  |  Branch (168:20): [True: 1.09k, False: 84.9k]
  ------------------
  169|       |            // not uncommon with [xxxx]: which should also be skipped
  170|  1.09k|            if (!skip_enclosed(sd, &rp, buf, "[", "]")) {
  ------------------
  |  Branch (170:17): [True: 695, False: 395]
  ------------------
  171|    695|                buf->pos = old_pos;
  172|    695|                return;
  173|    695|            }
  174|  84.9k|        } else if ((mp_isalpha(rp[0]) &&
  ------------------
  |  Branch (174:21): [True: 26.6k, False: 58.3k]
  ------------------
  175|  26.6k|                    (filter_harder || mp_isupper(rp[0]) || rp[0] == 'l')) ||
  ------------------
  |  Branch (175:22): [True: 0, False: 26.6k]
  |  Branch (175:39): [True: 23.1k, False: 3.50k]
  |  Branch (175:60): [True: 407, False: 3.09k]
  ------------------
  176|  61.4k|                   mp_isdigit(rp[0]) ||
  ------------------
  |  Branch (176:20): [True: 3.60k, False: 57.8k]
  ------------------
  177|  57.8k|                   rp[0] == ' ' || rp[0] == '\'' ||
  ------------------
  |  Branch (177:20): [True: 600, False: 57.2k]
  |  Branch (177:36): [True: 374, False: 56.8k]
  ------------------
  178|  56.8k|                   (filter_harder && (rp[0] == '(' || rp[0] == ')')) ||
  ------------------
  |  Branch (178:21): [True: 0, False: 56.8k]
  |  Branch (178:39): [True: 0, False: 0]
  |  Branch (178:55): [True: 0, False: 0]
  ------------------
  179|  56.8k|                   rp[0] == '#' || rp[0] == '.' || rp[0] == ',') {
  ------------------
  |  Branch (179:20): [True: 333, False: 56.5k]
  |  Branch (179:36): [True: 475, False: 56.0k]
  |  Branch (179:52): [True: 508, False: 55.5k]
  ------------------
  180|  29.4k|            rp++;
  181|  55.5k|        } else {
  182|  55.5k|            buf->pos = old_pos;
  183|  55.5k|            return;
  184|  55.5k|         }
  185|  87.0k|    }
  186|  5.02k|    if (!*rp) {
  ------------------
  |  Branch (186:9): [True: 4.04k, False: 982]
  ------------------
  187|       |        // : was not found
  188|  4.04k|        buf->pos = old_pos;
  189|  4.04k|        return;
  190|  4.04k|    }
  191|    982|    rp++; // skip :
  192|    982|    copy_ass(sd, &rp, buf);
  193|    982|    if (!*rp) {
  ------------------
  |  Branch (193:9): [True: 68, False: 914]
  ------------------
  194|       |        // end of data
  195|    914|    } else if (rp[0] == '\\' && rp[1] == 'N') {
  ------------------
  |  Branch (195:16): [True: 219, False: 695]
  |  Branch (195:33): [True: 175, False: 44]
  ------------------
  196|       |        // line end follows - skip it as line is empty
  197|    175|        rp += 2;
  198|    739|    } else if (rp[0] == ' ') {
  ------------------
  |  Branch (198:16): [True: 236, False: 503]
  ------------------
  199|    971|        while (rp[0] == ' ') {
  ------------------
  |  Branch (199:16): [True: 735, False: 236]
  ------------------
  200|    735|            rp++;
  201|    735|        }
  202|    236|        if (rp[0] == '\\' && rp[1] == 'N') {
  ------------------
  |  Branch (202:13): [True: 96, False: 140]
  |  Branch (202:30): [True: 21, False: 75]
  ------------------
  203|       |            // line end follows - skip it as line is empty
  204|     21|            rp += 2;
  205|     21|        }
  206|    503|    } else {
  207|       |        // non space follows - no speaker label
  208|    503|        buf->pos = old_pos;
  209|    503|        return;
  210|    503|    }
  211|    479|    *rpp = rp;
  212|    479|}
filter_sdh.c:copy_ass:
  113|  3.09M|{
  114|  3.09M|    char *rp = *rpp;
  115|       |
  116|  4.66M|    while (rp[0] == '{') {
  ------------------
  |  Branch (116:12): [True: 1.57M, False: 3.09M]
  ------------------
  117|   101M|        while (*rp) {
  ------------------
  |  Branch (117:16): [True: 101M, False: 10.4k]
  ------------------
  118|   101M|            char tmp = append(sd, buf, rp[0]);
  119|   101M|            rp++;
  120|   101M|            if (tmp == '}')
  ------------------
  |  Branch (120:17): [True: 1.56M, False: 99.6M]
  ------------------
  121|  1.56M|                break;
  122|   101M|        }
  123|  1.57M|    }
  124|  3.09M|    *rpp = rp;
  125|  3.09M|}
filter_sdh.c:matching_enclosure:
   89|  1.44M|{
   90|  1.44M|    int len = get_char_bytes(str);
   91|  5.42M|    for (int i = 0; len && enclosures && enclosures[i]; ++i) {
  ------------------
  |  Branch (91:21): [True: 5.33M, False: 86.9k]
  |  Branch (91:28): [True: 5.33M, False: 0]
  |  Branch (91:42): [True: 4.01M, False: 1.31M]
  ------------------
   92|  4.01M|        if (!strncmp(str, enclosures[i], len) &&
  ------------------
  |  Branch (92:13): [True: 40.6k, False: 3.97M]
  ------------------
   93|  40.6k|            len == get_char_bytes(enclosures[i]))  // str doesn't end early
  ------------------
  |  Branch (93:13): [True: 40.5k, False: 154]
  ------------------
   94|  40.5k|        {
   95|  40.5k|            return i;
   96|  40.5k|        }
   97|  4.01M|    }
   98|  1.40M|    return -1;
   99|  1.44M|}
filter_sdh.c:get_char_bytes:
   61|  1.61M|{
   62|       |    // In case the first character is non-ASCII.
   63|       |    // Will only work with UTF-8 but you shouldn't be
   64|       |    // using anything else anyway.
   65|  1.61M|    if (str && str[0]) {
  ------------------
  |  Branch (65:9): [True: 1.61M, False: 0]
  |  Branch (65:16): [True: 1.61M, False: 4.08k]
  ------------------
   66|  1.61M|        if (!(str[0] >> 7 & 1)) {
  ------------------
  |  Branch (66:13): [True: 1.03M, False: 581k]
  ------------------
   67|  1.03M|            return strnlen(str, 1);
   68|  1.03M|        } else if (!(str[0] >> 5 & 1)) {
  ------------------
  |  Branch (68:20): [True: 280k, False: 300k]
  ------------------
   69|   280k|            return strnlen(str, 2);
   70|   300k|        } else if (!(str[0] >> 4 & 1)) {
  ------------------
  |  Branch (70:20): [True: 209k, False: 91.6k]
  ------------------
   71|   209k|            return strnlen(str, 3);
   72|   209k|        } else if (!(str[0] >> 3 & 1)) {
  ------------------
  |  Branch (72:20): [True: 8.75k, False: 82.8k]
  ------------------
   73|  8.75k|            return strnlen(str, 4);
   74|  8.75k|        }
   75|  1.61M|    }
   76|  86.9k|    return 0;
   77|  1.61M|}
filter_sdh.c:skip_enclosed:
  237|  41.6k|{
  238|  41.6k|    bool filter_harder = sd->opts->sub_filter_SDH_harder;
  239|  41.6k|    char *rp = *rpp;
  240|  41.6k|    size_t old_pos = buf->pos;
  241|  41.6k|    bool parenthesis = is_parenthesis_pair(left, right);
  242|       |
  243|       |    // skip past the left character
  244|  41.6k|    rp += get_char_bytes(rp);
  245|       |    // skip past valid data searching for the right character
  246|  41.6k|    bool only_digits = parenthesis;
  247|  16.9M|    while (*rp && rp[0] != right[0]) {
  ------------------
  |  Branch (247:12): [True: 16.9M, False: 12.2k]
  |  Branch (247:19): [True: 16.9M, False: 8.03k]
  ------------------
  248|  16.9M|        if (rp[0] == '{') {
  ------------------
  |  Branch (248:13): [True: 1.52M, False: 15.4M]
  ------------------
  249|  1.52M|            copy_ass(sd, &rp, buf);
  250|  15.4M|        } else if (parenthesis && ((mp_isalpha(rp[0]) &&
  ------------------
  |  Branch (250:20): [True: 30.9k, False: 15.4M]
  |  Branch (250:37): [True: 2.87k, False: 28.0k]
  ------------------
  251|  2.87k|                    (filter_harder || mp_isupper(rp[0]) || rp[0] == 'l')) ||
  ------------------
  |  Branch (251:22): [True: 0, False: 2.87k]
  |  Branch (251:39): [True: 1.09k, False: 1.78k]
  |  Branch (251:60): [True: 278, False: 1.50k]
  ------------------
  252|  29.5k|                   mp_isdigit(rp[0]) ||
  ------------------
  |  Branch (252:20): [True: 1.34k, False: 28.2k]
  ------------------
  253|  28.2k|                   rp[0] == ' ' || rp[0] == '\'' || rp[0] == '#' ||
  ------------------
  |  Branch (253:20): [True: 2.89k, False: 25.3k]
  |  Branch (253:36): [True: 523, False: 24.8k]
  |  Branch (253:53): [True: 1.03k, False: 23.7k]
  ------------------
  254|  23.7k|                   rp[0] == '.' || rp[0] == ',' ||
  ------------------
  |  Branch (254:20): [True: 706, False: 23.0k]
  |  Branch (254:36): [True: 396, False: 22.6k]
  ------------------
  255|  22.6k|                   rp[0] == '-' || rp[0] == '"' || rp[0] == '\\')) {
  ------------------
  |  Branch (255:20): [True: 243, False: 22.4k]
  |  Branch (255:36): [True: 585, False: 21.8k]
  |  Branch (255:52): [True: 598, False: 21.2k]
  ------------------
  256|  9.68k|            if (!mp_isdigit(rp[0]))
  ------------------
  |  Branch (256:17): [True: 8.34k, False: 1.34k]
  ------------------
  257|  8.34k|                only_digits = false;
  258|  9.68k|            rp++;
  259|  15.4M|        } else if (parenthesis) {
  ------------------
  |  Branch (259:20): [True: 21.2k, False: 15.4M]
  ------------------
  260|  21.2k|            buf->pos = old_pos;
  261|  21.2k|            return false;
  262|  15.4M|        } else {
  263|  15.4M|            rp++;
  264|  15.4M|        }
  265|  16.9M|    }
  266|  20.3k|    if (!*rp) {
  ------------------
  |  Branch (266:9): [True: 12.2k, False: 8.03k]
  ------------------
  267|       |        // ) was not found
  268|  12.2k|        buf->pos = old_pos;
  269|  12.2k|        return false;
  270|  12.2k|    }
  271|  8.03k|    if (only_digits) {
  ------------------
  |  Branch (271:9): [True: 282, False: 7.75k]
  ------------------
  272|       |        // number within parentheses is probably not SDH
  273|    282|        buf->pos = old_pos;
  274|    282|        return false;
  275|    282|    }
  276|       |    // skip past the right character
  277|  7.75k|    rp += get_char_bytes(rp);
  278|       |    // skip trailing spaces
  279|  9.80k|    while (rp[0] == ' ') {
  ------------------
  |  Branch (279:12): [True: 2.04k, False: 7.75k]
  ------------------
  280|  2.04k|        rp++;
  281|  2.04k|    }
  282|  7.75k|    *rpp = rp;
  283|       |
  284|       |    return true;
  285|  8.03k|}
filter_sdh.c:is_parenthesis_pair:
   80|  41.6k|{
   81|  41.6k|    if (!strcmp(left, "(") && !strcmp(right, ")"))
  ------------------
  |  Branch (81:9): [True: 22.4k, False: 19.1k]
  |  Branch (81:31): [True: 22.4k, False: 0]
  ------------------
   82|  22.4k|        return true;
   83|  19.1k|    if (!strcmp(left, "\uFF08") && !strcmp(right, "\uFF09"))
  ------------------
  |  Branch (83:9): [True: 0, False: 19.1k]
  |  Branch (83:36): [True: 0, False: 0]
  ------------------
   84|      0|        return true;
   85|  19.1k|    return false;
   86|  19.1k|}
filter_sdh.c:append:
   49|   102M|{
   50|   102M|    if (buf->pos < buf->length) {
  ------------------
  |  Branch (50:9): [True: 102M, False: 0]
  ------------------
   51|   102M|        buf->string[buf->pos++] = c;
   52|   102M|    } else {
   53|       |        // ensure that terminating \0 is always written
   54|      0|        if (c == '\0')
  ------------------
  |  Branch (54:13): [True: 0, False: 0]
  ------------------
   55|      0|            buf->string[buf->length - 1] = c;
   56|      0|    }
   57|   102M|    return c;
   58|   102M|}
filter_sdh.c:remove_leading_hyphen_space:
  297|  5.32k|{
  298|  5.32k|    size_t old_pos = buf->pos;
  299|  5.32k|    if (start_pos >= old_pos)
  ------------------
  |  Branch (299:9): [True: 4.62k, False: 692]
  ------------------
  300|  4.62k|        return;
  301|    692|    append(sd, buf, '\0');  // \0 terminate for reading
  302|       |
  303|       |    // move past leading ass tags
  304|    824|    while (buf->string[start_pos] == '{') {
  ------------------
  |  Branch (304:12): [True: 132, False: 692]
  ------------------
  305|  3.26k|        while (buf->string[start_pos] && buf->string[start_pos] != '}') {
  ------------------
  |  Branch (305:16): [True: 3.26k, False: 0]
  |  Branch (305:42): [True: 3.13k, False: 132]
  ------------------
  306|  3.13k|            start_pos++;
  307|  3.13k|        }
  308|    132|        if (buf->string[start_pos])
  ------------------
  |  Branch (308:13): [True: 132, False: 0]
  ------------------
  309|    132|            start_pos++; // skip past '}'
  310|    132|    }
  311|       |
  312|       |    // if there is not a leading '-' no removing will be done
  313|    692|    if (buf->string[start_pos] != '-') {
  ------------------
  |  Branch (313:9): [True: 609, False: 83]
  ------------------
  314|    609|        buf->pos = old_pos;
  315|    609|        return;
  316|    609|    }
  317|       |
  318|     83|    char *rp = &buf->string[start_pos];  // read from here
  319|     83|    buf->pos = start_pos; // start writing here
  320|     83|    rp++; // skip '-'
  321|     83|    copy_ass(sd, &rp, buf);
  322|    109|    while (rp[0] == ' ') {
  ------------------
  |  Branch (322:12): [True: 26, False: 83]
  ------------------
  323|     26|        rp++; // skip ' '
  324|     26|        copy_ass(sd, &rp, buf);
  325|     26|    }
  326|    399|    while (*rp) {
  ------------------
  |  Branch (326:12): [True: 316, False: 83]
  ------------------
  327|       |        // copy the rest
  328|    316|        append(sd, buf, rp[0]);
  329|    316|        rp++;
  330|    316|    }
  331|     83|}

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

osd_res_equals:
  152|  1.78M|{
  153|  1.78M|    return a.w == b.w && a.h == b.h && a.ml == b.ml && a.mt == b.mt
  ------------------
  |  Branch (153:12): [True: 1.71M, False: 65.0k]
  |  Branch (153:26): [True: 1.71M, False: 0]
  |  Branch (153:40): [True: 1.71M, False: 0]
  |  Branch (153:56): [True: 1.71M, False: 0]
  ------------------
  154|  1.71M|        && a.mr == b.mr && a.mb == b.mb
  ------------------
  |  Branch (154:12): [True: 1.71M, False: 0]
  |  Branch (154:28): [True: 1.71M, False: 0]
  ------------------
  155|  1.71M|        && a.display_par == b.display_par;
  ------------------
  |  Branch (155:12): [True: 1.71M, False: 0]
  ------------------
  156|  1.78M|}
osd_create:
  159|  32.5k|{
  160|  32.5k|    static_assert(MAX_OSD_PARTS >= OSDTYPE_COUNT, "");
  161|       |
  162|  32.5k|    struct osd_state *osd = talloc_zero(NULL, struct osd_state);
  ------------------
  |  |   27|  32.5k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  32.5k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  32.5k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|  32.5k|    *osd = (struct osd_state) {
  164|  32.5k|        .opts_cache = m_config_cache_alloc(osd, global, &mp_osd_render_sub_opts),
  165|  32.5k|        .global = global,
  166|  32.5k|        .log = mp_log_new(osd, global->log, "osd"),
  167|  32.5k|        .force_video_pts = MP_NOPTS_VALUE,
  ------------------
  |  |   39|  32.5k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  168|  32.5k|        .stats = stats_ctx_create(osd, global, "osd"),
  169|  32.5k|    };
  170|  32.5k|    mp_mutex_init(&osd->lock);
  171|  32.5k|    osd->opts = osd->opts_cache->opts;
  172|       |
  173|   227k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|   227k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (173:21): [True: 195k, False: 32.5k]
  ------------------
  174|   195k|        struct osd_object *obj = talloc(osd, struct osd_object);
  ------------------
  |  |   26|   195k|#define talloc                          ta_xnew
  |  |  ------------------
  |  |  |  |  133|   195k|#define ta_xnew(...)                    ta_oom_g(ta_new(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   195k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|   195k|        *obj = (struct osd_object) {
  176|   195k|            .type = n,
  177|   195k|            .text = talloc_strdup(obj, ""),
  ------------------
  |  |   50|   195k|#define talloc_strdup                   ta_xstrdup
  ------------------
  178|   195k|            .progbar_state = {.type = -1},
  179|   195k|            .vo_change_id = 1,
  180|   195k|        };
  181|   195k|        osd->objs[n] = obj;
  182|   195k|    }
  183|       |
  184|  32.5k|    osd->objs[OSDTYPE_SUB]->is_sub = true;
  185|  32.5k|    osd->objs[OSDTYPE_SUB2]->is_sub = true;
  186|       |
  187|  32.5k|    return osd;
  188|  32.5k|}
osd_free:
  191|  32.5k|{
  192|  32.5k|    if (!osd)
  ------------------
  |  Branch (192:9): [True: 0, False: 32.5k]
  ------------------
  193|      0|        return;
  194|  32.5k|    osd_destroy_backend(osd);
  195|  32.5k|    talloc_free(osd->objs[OSDTYPE_EXTERNAL2]->image_overlay);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  196|  32.5k|    talloc_free(osd->objs[OSDTYPE_DISC_MENU]->image_overlay);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  197|  32.5k|    mp_mutex_destroy(&osd->lock);
  ------------------
  |  |  133|  32.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
  198|  32.5k|    talloc_free(osd);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  199|  32.5k|}
osd_set_text:
  202|  2.37k|{
  203|  2.37k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  2.37k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  204|  2.37k|    struct osd_object *osd_obj = osd->objs[OSDTYPE_OSD];
  205|  2.37k|    if (!text)
  ------------------
  |  Branch (205:9): [True: 2.37k, False: 0]
  ------------------
  206|  2.37k|        text = "";
  207|  2.37k|    if (strcmp(osd_obj->text, text) != 0) {
  ------------------
  |  Branch (207:9): [True: 0, False: 2.37k]
  ------------------
  208|      0|        talloc_free(osd_obj->text);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  209|      0|        osd_obj->text = talloc_strdup(osd_obj, text);
  ------------------
  |  |   50|      0|#define talloc_strdup                   ta_xstrdup
  ------------------
  210|      0|        osd_obj->osd_changed = true;
  211|      0|        osd->want_redraw_notification = true;
  212|      0|    }
  213|  2.37k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  2.37k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  214|  2.37k|}
osd_set_sub:
  217|  13.3k|{
  218|  13.3k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  13.3k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  219|  13.3k|    if (index >= 0 && index < 2) {
  ------------------
  |  Branch (219:9): [True: 13.3k, False: 0]
  |  Branch (219:23): [True: 13.3k, False: 0]
  ------------------
  220|  13.3k|        struct osd_object *obj = osd->objs[OSDTYPE_SUB + index];
  221|  13.3k|        obj->sub = dec_sub;
  222|  13.3k|        obj->vo_change_id += 1;
  223|  13.3k|    }
  224|  13.3k|    osd->want_redraw_notification = true;
  225|  13.3k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  13.3k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  226|  13.3k|}
osd_get_render_subs_in_filter:
  229|   812k|{
  230|   812k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|   812k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  231|   812k|    bool r = osd->render_subs_in_filter;
  232|   812k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|   812k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  233|   812k|    return r;
  234|   812k|}
osd_set_render_subs_in_filter:
  237|   845k|{
  238|   845k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|   845k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  239|   845k|    if (osd->render_subs_in_filter != s) {
  ------------------
  |  Branch (239:9): [True: 65.0k, False: 780k]
  ------------------
  240|  65.0k|        osd->render_subs_in_filter = s;
  241|       |
  242|  65.0k|        int change_id = 0;
  243|   455k|        for (int n = 0; n < MAX_OSD_PARTS; n++)
  ------------------
  |  |  127|   455k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (243:25): [True: 390k, False: 65.0k]
  ------------------
  244|   390k|            change_id = MPMAX(change_id, osd->objs[n]->vo_change_id);
  ------------------
  |  |   44|   390k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 33.3k, False: 356k]
  |  |  ------------------
  ------------------
  245|   455k|        for (int n = 0; n < MAX_OSD_PARTS; n++)
  ------------------
  |  |  127|   455k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (245:25): [True: 390k, False: 65.0k]
  ------------------
  246|   390k|            osd->objs[n]->vo_change_id = change_id + 1;
  247|  65.0k|    }
  248|   845k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|   845k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  249|   845k|}
osd_set_force_video_pts:
  252|   815k|{
  253|       |    atomic_store(&osd->force_video_pts, video_pts);
  254|   815k|}
osd_get_force_video_pts:
  257|   512k|{
  258|       |    return atomic_load(&osd->force_video_pts);
  259|   512k|}
osd_set_bitmaps:
  279|  32.5k|{
  280|  32.5k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  32.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  281|  32.5k|    struct osd_object *obj = osd->objs[type];
  282|  32.5k|    talloc_free(obj->image_overlay);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  283|  32.5k|    obj->image_overlay = sub_bitmaps_copy(NULL, imgs);
  284|  32.5k|    obj->vo_change_id += 1;
  285|  32.5k|    osd->want_redraw_notification = true;
  286|  32.5k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  32.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  287|  32.5k|}
osd_render:
  368|   812k|{
  369|   812k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|   812k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  370|       |
  371|   812k|    int64_t start_time = mp_time_ns();
  372|       |
  373|   812k|    struct sub_bitmap_list *list = talloc_zero(NULL, struct sub_bitmap_list);
  ------------------
  |  |   27|   812k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|   812k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|   812k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|   812k|    list->change_id = 1;
  375|   812k|    list->w = res.w;
  376|   812k|    list->h = res.h;
  377|       |
  378|   812k|    double force_video_pts = atomic_load(&osd->force_video_pts);
  379|   812k|    if (force_video_pts != MP_NOPTS_VALUE)
  ------------------
  |  |   39|   812k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (379:9): [True: 0, False: 812k]
  ------------------
  380|      0|        video_pts = force_video_pts;
  381|       |
  382|   812k|    if (draw_flags & OSD_DRAW_SUB_FILTER)
  ------------------
  |  Branch (382:9): [True: 812k, False: 0]
  ------------------
  383|   812k|        draw_flags |= OSD_DRAW_SUB_ONLY;
  384|       |
  385|  5.69M|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|  5.69M|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (385:21): [True: 4.87M, False: 812k]
  ------------------
  386|  4.87M|        struct osd_object *obj = osd->objs[n];
  387|       |
  388|       |        // Object is drawn into the video frame itself; don't draw twice
  389|  4.87M|        if (osd->render_subs_in_filter && obj->is_sub &&
  ------------------
  |  Branch (389:13): [True: 4.87M, False: 0]
  |  Branch (389:43): [True: 1.62M, False: 3.25M]
  ------------------
  390|  1.62M|            !(draw_flags & OSD_DRAW_SUB_FILTER))
  ------------------
  |  Branch (390:13): [True: 0, False: 1.62M]
  ------------------
  391|      0|            continue;
  392|  4.87M|        if ((draw_flags & OSD_DRAW_SUB_ONLY) && !obj->is_sub)
  ------------------
  |  Branch (392:13): [True: 4.87M, False: 0]
  |  Branch (392:49): [True: 3.25M, False: 1.62M]
  ------------------
  393|  3.25M|            continue;
  394|  1.62M|        if ((draw_flags & OSD_DRAW_OSD_ONLY) && obj->is_sub)
  ------------------
  |  Branch (394:13): [True: 0, False: 1.62M]
  |  Branch (394:49): [True: 0, False: 0]
  ------------------
  395|      0|            continue;
  396|       |
  397|  1.62M|        char *stat_type_render = obj->is_sub ? "sub-render" : "osd-render";
  ------------------
  |  Branch (397:34): [True: 1.62M, False: 0]
  ------------------
  398|  1.62M|        stats_time_start(osd->stats, stat_type_render);
  399|       |
  400|  1.62M|        struct sub_bitmaps *imgs =
  401|  1.62M|            render_object(osd, obj, res, video_pts, formats);
  402|       |
  403|  1.62M|        stats_time_end(osd->stats, stat_type_render);
  404|       |
  405|  1.62M|        if (imgs && imgs->num_parts > 0) {
  ------------------
  |  Branch (405:13): [True: 0, False: 1.62M]
  |  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|  1.62M|        list->change_id += obj->vo_change_id;
  417|       |
  418|  1.62M|        talloc_free(imgs);
  ------------------
  |  |   47|  1.62M|#define talloc_free                     ta_free
  ------------------
  419|  1.62M|    }
  420|       |
  421|   812k|    double elapsed = MP_TIME_NS_TO_MS(mp_time_ns() - start_time);
  ------------------
  |  |   77|   812k|#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000)
  ------------------
  422|   812k|    bool slow = elapsed > 5;
  423|   812k|    mp_msg(osd->log, slow ? MSGL_DEBUG : MSGL_TRACE, "Spent %.3f ms in %s%s\n",
  ------------------
  |  Branch (423:22): [True: 1.36k, False: 811k]
  ------------------
  424|   812k|           elapsed, __func__, slow ? " (slow!)" : "");
  ------------------
  |  Branch (424:31): [True: 1.36k, False: 811k]
  ------------------
  425|       |
  426|   812k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|   812k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  427|   812k|    return list;
  428|   812k|}
osd_draw_on_image_p:
  463|   812k|{
  464|   812k|    struct sub_bitmap_list *list =
  465|   812k|        osd_render(osd, res, video_pts, draw_flags, mp_draw_sub_formats);
  466|       |
  467|   812k|    if (!list->num_items) {
  ------------------
  |  Branch (467:9): [True: 812k, False: 0]
  ------------------
  468|   812k|        talloc_free(list);
  ------------------
  |  |   47|   812k|#define talloc_free                     ta_free
  ------------------
  469|   812k|        return;
  470|   812k|    }
  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_changed:
  508|  32.5k|{
  509|  32.5k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  32.5k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  510|  32.5k|    osd->objs[OSDTYPE_OSD]->osd_changed = true;
  511|  32.5k|    osd->want_redraw_notification = true;
  512|       |    // Done here for a lack of a better place.
  513|  32.5k|    m_config_cache_update(osd->opts_cache);
  514|  32.5k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  32.5k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  515|  32.5k|}
osd_query_and_reset_want_redraw:
  518|    356|{
  519|    356|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|    356|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  520|    356|    bool r = osd->want_redraw_notification;
  521|    356|    osd->want_redraw_notification = false;
  522|    356|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|    356|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  523|    356|    return r;
  524|    356|}
sub_bitmaps_copy:
  585|   193k|{
  586|   193k|    if (!in || !in->num_parts)
  ------------------
  |  Branch (586:9): [True: 32.5k, False: 161k]
  |  Branch (586:16): [True: 161k, False: 0]
  ------------------
  587|   193k|        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|  1.62M|{
  292|  1.62M|    if (!osd_res_equals(res, obj->vo_res)) {
  ------------------
  |  Branch (292:9): [True: 65.0k, False: 1.56M]
  ------------------
  293|  65.0k|        obj->vo_res = res;
  294|  65.0k|        obj->osd_changed = true;
  295|  65.0k|        mp_client_broadcast_event_external(osd->global->client_api,
  296|       |                                           MP_EVENT_WIN_RESIZE, NULL);
  297|  65.0k|    }
  298|  1.62M|}
osd.c:render_object:
  321|  1.62M|{
  322|  1.62M|    int format = SUBBITMAP_LIBASS;
  323|  1.62M|    if (!sub_formats[format] || osd->opts->force_rgba_osd)
  ------------------
  |  Branch (323:9): [True: 0, False: 1.62M]
  |  Branch (323:33): [True: 0, False: 1.62M]
  ------------------
  324|      0|        format = SUBBITMAP_BGRA;
  325|       |
  326|  1.62M|    struct sub_bitmaps *res = NULL;
  327|       |
  328|  1.62M|    check_obj_resize(osd, osdres, obj);
  329|       |
  330|  1.62M|    if (obj->type == OSDTYPE_SUB) {
  ------------------
  |  Branch (330:9): [True: 812k, False: 812k]
  ------------------
  331|   812k|        if (obj->sub && sub_is_primary_visible(obj->sub))
  ------------------
  |  Branch (331:13): [True: 166k, False: 646k]
  |  Branch (331:25): [True: 166k, False: 0]
  ------------------
  332|   166k|            res = sub_get_bitmaps(obj->sub, obj->vo_res, format, video_pts);
  333|   812k|    } else if (obj->type == OSDTYPE_SUB2) {
  ------------------
  |  Branch (333:16): [True: 812k, False: 0]
  ------------------
  334|   812k|        if (obj->sub && sub_is_secondary_visible(obj->sub))
  ------------------
  |  Branch (334:13): [True: 0, False: 812k]
  |  Branch (334:25): [True: 0, False: 0]
  ------------------
  335|      0|            res = sub_get_bitmaps(obj->sub, obj->vo_res, format, video_pts);
  336|   812k|    } 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|  1.62M|    if (obj->vo_had_output != !!res) {
  ------------------
  |  Branch (346:9): [True: 0, False: 1.62M]
  ------------------
  347|      0|        obj->vo_had_output = !!res;
  348|      0|        obj->vo_change_id += 1;
  349|      0|    }
  350|       |
  351|  1.62M|    if (res) {
  ------------------
  |  Branch (351:9): [True: 0, False: 1.62M]
  ------------------
  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|  1.62M|    return res;
  359|  1.62M|}

osd_destroy_backend:
   86|  32.5k|{
   87|   227k|    for (int n = 0; n < MAX_OSD_PARTS; n++) {
  ------------------
  |  |  127|   227k|#define MAX_OSD_PARTS 6
  ------------------
  |  Branch (87:21): [True: 195k, False: 32.5k]
  ------------------
   88|   195k|        struct osd_object *obj = osd->objs[n];
   89|   195k|        destroy_ass_renderer(&obj->ass);
   90|   195k|        for (int i = 0; i < obj->num_externals; i++)
  ------------------
  |  Branch (90:25): [True: 0, False: 195k]
  ------------------
   91|      0|            destroy_external(obj->externals[i]);
   92|   195k|        obj->num_externals = 0;
   93|   195k|    }
   94|  32.5k|}
osd_set_external_remove_owner:
  648|  65.0k|{
  649|  65.0k|    mp_mutex_lock(&osd->lock);
  ------------------
  |  |  134|  65.0k|#define mp_mutex_lock       pthread_mutex_lock
  ------------------
  650|  65.0k|    struct osd_object *obj = osd->objs[OSDTYPE_EXTERNAL];
  651|  65.0k|    for (int n = obj->num_externals - 1; n >= 0; n--) {
  ------------------
  |  Branch (651:42): [True: 0, False: 65.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|  65.0k|    mp_mutex_unlock(&osd->lock);
  ------------------
  |  |  136|  65.0k|#define mp_mutex_unlock     pthread_mutex_unlock
  ------------------
  661|  65.0k|}
osd_libass.c:destroy_ass_renderer:
   65|   195k|{
   66|   195k|    if (ass->track)
  ------------------
  |  Branch (66:9): [True: 0, False: 195k]
  ------------------
   67|      0|        ass_free_track(ass->track);
   68|   195k|    ass->track = NULL;
   69|   195k|    if (ass->render)
  ------------------
  |  Branch (69:9): [True: 0, False: 195k]
  ------------------
   70|      0|        ass_renderer_done(ass->render);
   71|   195k|    ass->render = NULL;
   72|   195k|    if (ass->library)
  ------------------
  |  Branch (72:9): [True: 0, False: 195k]
  ------------------
   73|      0|        ass_library_done(ass->library);
   74|   195k|    ass->library = NULL;
   75|   195k|    talloc_free(ass->log);
  ------------------
  |  |   47|   195k|#define talloc_free                     ta_free
  ------------------
   76|       |    ass->log = NULL;
   77|   195k|}

mp_sub_packer_alloc:
   52|  6.45k|{
   53|  6.45k|    struct mp_sub_packer *p = talloc_zero(ta_parent, struct mp_sub_packer);
  ------------------
  |  |   27|  6.45k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  6.45k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  6.45k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   54|  6.45k|    p->packer = talloc_zero(p, struct bitmap_packer);
  ------------------
  |  |   27|  6.45k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  6.45k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  6.45k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  6.45k|    p->packer->padding = 1; // assume bilinear sampling
   56|  6.45k|    return p;
   57|  6.45k|}
mp_sub_packer_pack_ass:
  275|   161k|{
  276|   161k|    int format = preferred_osd_format == SUBBITMAP_BGRA ? SUBBITMAP_BGRA
  ------------------
  |  Branch (276:18): [True: 0, False: 161k]
  ------------------
  277|   161k|                                                        : SUBBITMAP_LIBASS;
  278|       |
  279|   161k|    if (p->cached_subs_valid && !image_lists_changed &&
  ------------------
  |  Branch (279:9): [True: 0, False: 161k]
  |  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|   161k|    *out = (struct sub_bitmaps){.change_id = 1};
  287|   161k|    p->cached_subs_valid = false;
  288|       |
  289|   161k|    struct sub_bitmaps res = {
  290|   161k|        .change_id = image_lists_changed,
  291|   161k|        .format = SUBBITMAP_LIBASS,
  292|   161k|        .parts = p->cached_parts,
  293|   161k|        .video_color_space = video_color_space,
  294|   161k|    };
  295|       |
  296|   322k|    for (int n = 0; n < num_image_lists; n++) {
  ------------------
  |  Branch (296:21): [True: 161k, False: 161k]
  ------------------
  297|   161k|        for (struct ass_image *img = image_lists[n]; img; img = img->next) {
  ------------------
  |  Branch (297:54): [True: 0, False: 161k]
  ------------------
  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|   161k|    }
  313|       |
  314|   161k|    bool r = false;
  315|   161k|    if (format == SUBBITMAP_BGRA) {
  ------------------
  |  Branch (315:9): [True: 0, False: 161k]
  ------------------
  316|      0|        r = pack_rgba(p, &res);
  317|   161k|    } else {
  318|   161k|        r = pack_libass(p, &res);
  319|   161k|    }
  320|       |
  321|   161k|    if (!r)
  ------------------
  |  Branch (321:9): [True: 161k, False: 0]
  ------------------
  322|   161k|        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|   161k|{
   61|   161k|    packer_set_size(p->packer, res->num_parts);
   62|       |
   63|   161k|    for (int n = 0; n < res->num_parts; n++)
  ------------------
  |  Branch (63:21): [True: 0, False: 161k]
  ------------------
   64|      0|        p->packer->in[n] = (struct pos){res->parts[n].w, res->parts[n].h};
   65|       |
   66|   161k|    if (p->packer->count == 0 || packer_pack(p->packer) < 0)
  ------------------
  |  Branch (66:9): [True: 161k, False: 0]
  |  Branch (66:34): [True: 0, False: 0]
  ------------------
   67|   161k|        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|   161k|{
  189|   161k|    if (!pack(p, res, IMGFMT_Y8))
  ------------------
  |  Branch (189:9): [True: 161k, False: 0]
  ------------------
  190|   161k|        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|   161k|}

sd_ass_fmt_offset:
 1241|  6.45k|{
 1242|       |    // "Text" is always last (as it's arbitrary content in buf), e.g. format:
 1243|       |    // "Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
 1244|  6.45k|    int n = 0;
 1245|  64.5k|    while (evt_fmt && (evt_fmt = strchr(evt_fmt, ',')))
  ------------------
  |  Branch (1245:12): [True: 64.5k, False: 0]
  |  Branch (1245:23): [True: 58.0k, False: 6.45k]
  ------------------
 1246|  58.0k|         evt_fmt++, n++;
 1247|  6.45k|    return n-1;  // buffer is without the format's Start/End, with ReadOrder
 1248|  6.45k|}
sd_ass_pkt_text:
 1251|  62.4k|{
 1252|       |    // e.g. pkt->buffer ("4" is ReadOrder): "4,0,Default,,0,0,0,,fifth line"
 1253|  62.4k|    bstr txt = {(char *)pkt->buffer, pkt->len}, t0 = txt;
 1254|   562k|    while (offset-- > 0) {
  ------------------
  |  Branch (1254:12): [True: 499k, False: 62.4k]
  ------------------
 1255|   499k|        int n = bstrchr(txt, ',');
 1256|   499k|        if (n < 0) {  // shouldn't happen
  ------------------
  |  Branch (1256:13): [True: 0, False: 499k]
  ------------------
 1257|      0|            MP_WARN(ft, "Malformed event '%.*s'\n", BSTR_P(t0));
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1258|      0|            return (bstr){NULL, 0};
 1259|      0|        }
 1260|   499k|        txt = bstr_cut(txt, n+1);
 1261|   499k|    }
 1262|  62.4k|    return txt;
 1263|  62.4k|}
sd_ass.c:init:
  304|  6.47k|{
  305|  6.47k|    struct sd_ass_priv *ctx = talloc_zero(sd, struct sd_ass_priv);
  ------------------
  |  |   27|  6.47k|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|  6.47k|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  6.47k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|  6.47k|    sd->priv = ctx;
  307|       |
  308|       |    // Note: accept "null" as alias for "ass", so EDL delay_open subtitle
  309|       |    //       streams work.
  310|  6.47k|    if (strcmp(sd->codec->codec, "ass") != 0 &&
  ------------------
  |  Branch (310:9): [True: 5.93k, False: 543]
  ------------------
  311|  5.93k|        strcmp(sd->codec->codec, "null") != 0)
  ------------------
  |  Branch (311:9): [True: 5.93k, False: 0]
  ------------------
  312|  5.93k|    {
  313|  5.93k|        ctx->is_converted = true;
  314|  5.93k|        ctx->converter = lavc_conv_create(sd);
  315|  5.93k|        if (!ctx->converter)
  ------------------
  |  Branch (315:13): [True: 25, False: 5.91k]
  ------------------
  316|     25|            return -1;
  317|  5.93k|    }
  318|       |
  319|  6.45k|    assobjects_init(sd);
  320|  6.45k|    filters_init(sd);
  321|       |
  322|  6.45k|    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|  6.45k|    const char *_Atomic *desc = ctx->converter ? &sd->codec->codec_profile : &sd->codec->codec_desc;
  ------------------
  |  Branch (325:33): [True: 5.91k, False: 543]
  ------------------
  326|  6.45k|    switch (ctx->ass_track->track_type) {
  ------------------
  |  Branch (326:13): [True: 6.45k, False: 0]
  ------------------
  327|  6.40k|    case TRACK_TYPE_ASS:
  ------------------
  |  Branch (327:5): [True: 6.40k, False: 44]
  ------------------
  328|  6.40k|        *desc = "Advanced Sub Station Alpha";
  329|  6.40k|        break;
  330|     44|    case TRACK_TYPE_SSA:
  ------------------
  |  Branch (330:5): [True: 44, False: 6.40k]
  ------------------
  331|     44|        *desc = "Sub Station Alpha";
  332|     44|        break;
  333|  6.45k|    }
  334|       |
  335|  6.45k|    return 0;
  336|  6.45k|}
sd_ass.c:assobjects_init:
  249|  6.45k|{
  250|  6.45k|    struct sd_ass_priv *ctx = sd->priv;
  251|  6.45k|    struct mp_subtitle_opts *opts = sd->opts;
  252|  6.45k|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  253|       |
  254|  6.45k|    ctx->ass_library = mp_ass_init(sd->global, sd->opts->sub_style, sd->log);
  255|  6.45k|    ass_set_extract_fonts(ctx->ass_library, opts->use_embedded_fonts);
  256|       |
  257|  6.45k|    add_subtitle_fonts(sd);
  258|       |
  259|  6.45k|    if (shared_opts->ass_style_override[sd->order])
  ------------------
  |  Branch (259:9): [True: 6.45k, False: 0]
  ------------------
  260|  6.45k|        ass_set_style_overrides(ctx->ass_library, opts->ass_style_override_list);
  261|       |
  262|  6.45k|    ctx->ass_track = ass_new_track(ctx->ass_library);
  263|  6.45k|    ctx->ass_track->track_type = TRACK_TYPE_ASS;
  264|       |
  265|  6.45k|    ctx->shadow_track = ass_new_track(ctx->ass_library);
  266|  6.45k|    ctx->shadow_track->PlayResX = MP_ASS_FONT_PLAYRESX;
  ------------------
  |  |   31|  6.45k|#define MP_ASS_FONT_PLAYRESX 384
  ------------------
  267|  6.45k|    ctx->shadow_track->PlayResY = MP_ASS_FONT_PLAYRESY;
  ------------------
  |  |   32|  6.45k|#define MP_ASS_FONT_PLAYRESY 288
  ------------------
  268|  6.45k|    mp_ass_add_default_styles(sd, ctx->shadow_track, opts, shared_opts);
  269|       |
  270|  6.45k|    char *extradata = sd->codec->extradata;
  271|  6.45k|    int extradata_size = sd->codec->extradata_size;
  272|  6.45k|    if (ctx->converter) {
  ------------------
  |  Branch (272:9): [True: 5.91k, False: 543]
  ------------------
  273|  5.91k|        extradata = lavc_conv_get_extradata(ctx->converter);
  274|  5.91k|        extradata_size = extradata ? strlen(extradata) : 0;
  ------------------
  |  Branch (274:26): [True: 5.91k, False: 0]
  ------------------
  275|  5.91k|    }
  276|  6.45k|    if (extradata)
  ------------------
  |  Branch (276:9): [True: 6.45k, False: 0]
  ------------------
  277|  6.45k|        ass_process_codec_private(ctx->ass_track, extradata, extradata_size);
  278|       |
  279|  6.45k|    mp_ass_add_default_styles(sd, ctx->ass_track, opts, shared_opts);
  280|       |
  281|  6.45k|#if LIBASS_VERSION >= 0x01302000
  282|  6.45k|    ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1);
  ------------------
  |  Branch (282:45): [True: 0, False: 6.45k]
  ------------------
  283|  6.45k|#endif
  284|       |
  285|  6.45k|#if LIBASS_VERSION >= 0x01703010
  286|  6.45k|    ass_configure_prune(ctx->ass_track, sd->opts->ass_prune_delay * 1000.0);
  287|  6.45k|#endif
  288|       |
  289|       |    enable_output(sd, true);
  290|  6.45k|    ass_set_cache_limits(ctx->ass_renderer, sd->opts->sub_glyph_limit, sd->opts->sub_bitmap_max_size);
  291|  6.45k|}
sd_ass.c:add_subtitle_fonts:
  182|  6.45k|{
  183|  6.45k|    struct sd_ass_priv *ctx = sd->priv;
  184|  6.45k|    struct mp_subtitle_opts *opts = sd->opts;
  185|  6.45k|    if (!opts->ass_enabled || !opts->use_embedded_fonts || !sd->attachments)
  ------------------
  |  Branch (185:9): [True: 0, False: 6.45k]
  |  Branch (185:31): [True: 0, False: 6.45k]
  |  Branch (185:60): [True: 0, False: 6.45k]
  ------------------
  186|      0|        return;
  187|  6.45k|    for (int i = 0; i < sd->attachments->num_entries; i++) {
  ------------------
  |  Branch (187:21): [True: 0, False: 6.45k]
  ------------------
  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|  6.45k|}
sd_ass.c:mp_ass_add_default_styles:
  119|  12.9k|{
  120|  12.9k|    if (opts->ass_styles_file && shared_opts->ass_style_override[sd->order]) {
  ------------------
  |  Branch (120:9): [True: 0, False: 12.9k]
  |  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|  12.9k|    if (track->n_styles == 0) {
  ------------------
  |  Branch (126:9): [True: 0, False: 12.9k]
  ------------------
  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|  12.9k|    if (shared_opts->ass_style_override[sd->order])
  ------------------
  |  Branch (139:9): [True: 12.9k, False: 0]
  ------------------
  140|  12.9k|        ass_process_force_style(track);
  141|  12.9k|}
sd_ass.c:filters_init:
  208|  6.45k|{
  209|  6.45k|    struct sd_ass_priv *ctx = sd->priv;
  210|       |
  211|  6.45k|    filters_destroy(sd);
  212|       |
  213|  19.3k|    for (int n = 0; filters[n]; n++) {
  ------------------
  |  Branch (213:21): [True: 12.9k, False: 6.45k]
  ------------------
  214|  12.9k|        struct sd_filter *ft = talloc_ptrtype(ctx, ft);
  ------------------
  |  |   34|  12.9k|#define talloc_ptrtype                  ta_xnew_ptrtype
  |  |  ------------------
  |  |  |  |  138|  12.9k|#define ta_xnew_ptrtype(...)            ta_oom_g(ta_new_ptrtype(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|  12.9k|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|  12.9k|        *ft = (struct sd_filter){
  216|  12.9k|            .global = sd->global,
  217|  12.9k|            .log = sd->log,
  218|  12.9k|            .packet_pool = demux_packet_pool_get(sd->global),
  219|  12.9k|            .opts = mp_get_config_group(ft, sd->global, &mp_sub_filter_opts),
  220|  12.9k|            .driver = filters[n],
  221|  12.9k|            .codec = "ass",
  222|  12.9k|            .event_format = talloc_strdup(ft, ctx->ass_track->event_format),
  ------------------
  |  |   50|  12.9k|#define talloc_strdup                   ta_xstrdup
  ------------------
  223|  12.9k|        };
  224|  12.9k|        if (ft->driver->init(ft)) {
  ------------------
  |  Branch (224:13): [True: 6.45k, False: 6.45k]
  ------------------
  225|  6.45k|            MP_TARRAY_APPEND(ctx, ctx->filters, ctx->num_filters, ft);
  ------------------
  |  |  105|  6.45k|    do {                                            \
  |  |  106|  6.45k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  6.45k|    do {                                            \
  |  |  |  |   97|  6.45k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  6.45k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  6.45k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  6.45k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 6.45k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|  6.45k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  6.45k|    do {                                                        \
  |  |  |  |  |  |   89|  6.45k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  6.45k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  6.45k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  6.45k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  6.45k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  6.45k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  6.45k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 6.45k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  6.45k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 6.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|  6.45k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|  6.45k|        (idxvar)++;                                 \
  |  |  109|  6.45k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 6.45k]
  |  |  ------------------
  ------------------
  226|  6.45k|        } else {
  227|  6.45k|            talloc_free(ft);
  ------------------
  |  |   47|  6.45k|#define talloc_free                     ta_free
  ------------------
  228|  6.45k|        }
  229|  12.9k|    }
  230|  6.45k|}
sd_ass.c:filters_destroy:
  195|  12.9k|{
  196|  12.9k|    struct sd_ass_priv *ctx = sd->priv;
  197|       |
  198|  19.3k|    for (int n = 0; n < ctx->num_filters; n++) {
  ------------------
  |  Branch (198:21): [True: 6.45k, False: 12.9k]
  ------------------
  199|  6.45k|        struct sd_filter *ft = ctx->filters[n];
  200|  6.45k|        if (ft->driver->uninit)
  ------------------
  |  Branch (200:13): [True: 0, False: 6.45k]
  ------------------
  201|      0|            ft->driver->uninit(ft);
  202|  6.45k|        talloc_free(ft);
  ------------------
  |  |   47|  6.45k|#define talloc_free                     ta_free
  ------------------
  203|  6.45k|    }
  204|  12.9k|    ctx->num_filters = 0;
  205|  12.9k|}
sd_ass.c:decode:
  468|  63.0k|{
  469|  63.0k|    struct sd_ass_priv *ctx = sd->priv;
  470|  63.0k|    ASS_Track *track = ctx->ass_track;
  471|       |
  472|  63.0k|    packet->sub_duration = packet->duration;
  473|       |
  474|  63.0k|    if (ctx->converter) {
  ------------------
  |  Branch (474:9): [True: 63.0k, False: 0]
  ------------------
  475|  63.0k|        if (!sd->opts->sub_clear_on_seek && check_packet_seen(sd, packet))
  ------------------
  |  Branch (475:13): [True: 63.0k, False: 0]
  |  Branch (475:45): [True: 170, False: 62.8k]
  ------------------
  476|    170|            return;
  477|       |
  478|  62.8k|        double sub_pts = 0;
  479|  62.8k|        double sub_duration = 0;
  480|  62.8k|        char **r = lavc_conv_decode(ctx->converter, packet, &sub_pts,
  481|  62.8k|                                    &sub_duration);
  482|  62.8k|        if (sd->opts->sub_stretch_durations ||
  ------------------
  |  Branch (482:13): [True: 0, False: 62.8k]
  ------------------
  483|  62.8k|            packet->duration < 0 || sub_duration == UINT32_MAX) {
  ------------------
  |  Branch (483:13): [True: 4.64k, False: 58.2k]
  |  Branch (483:37): [True: 0, False: 58.2k]
  ------------------
  484|  4.64k|            MP_VERBOSE(sd, "Subtitle with unknown duration.\n");
  ------------------
  |  |   92|  4.64k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  4.64k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  485|  4.64k|            sub_duration = UNKNOWN_DURATION;
  ------------------
  |  |  465|  4.64k|#define UNKNOWN_DURATION (INT_MAX / 1000)
  ------------------
  486|  4.64k|        }
  487|       |
  488|   125k|        for (int n = 0; r && r[n]; n++) {
  ------------------
  |  Branch (488:25): [True: 125k, False: 0]
  |  Branch (488:30): [True: 62.4k, False: 62.8k]
  ------------------
  489|  62.4k|            struct demux_packet pkt2 = {
  490|  62.4k|                .pts = sub_pts,
  491|  62.4k|                .duration = sub_duration,
  492|  62.4k|                .buffer = r[n],
  493|  62.4k|                .len = strlen(r[n]),
  494|  62.4k|            };
  495|  62.4k|            filter_and_add(sd, &pkt2);
  496|  62.4k|        }
  497|  5.06M|        for (int n = track->n_events - 1; n >= 0; n--) {
  ------------------
  |  Branch (497:43): [True: 5.02M, False: 38.8k]
  ------------------
  498|  5.02M|            if (track->events[track->n_events - 1].Start == track->events[n].Start)
  ------------------
  |  Branch (498:17): [True: 4.22M, False: 797k]
  ------------------
  499|  4.22M|                continue;
  500|   797k|            if (track->events[n].Duration == UNKNOWN_DURATION * 1000) {
  ------------------
  |  |  465|   797k|#define UNKNOWN_DURATION (INT_MAX / 1000)
  ------------------
  |  Branch (500:17): [True: 1, False: 797k]
  ------------------
  501|      1|                if (track->events[n].Start < track->events[n + 1].Start) {
  ------------------
  |  Branch (501:21): [True: 1, False: 0]
  ------------------
  502|      1|                    track->events[n].Duration = track->events[n + 1].Start -
  503|      1|                                                track->events[n].Start;
  504|      1|                } 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|      1|            }
  508|   797k|            if (n > 0 && track->events[n].Start != track->events[n - 1].Start)
  ------------------
  |  Branch (508:17): [True: 786k, False: 11.1k]
  |  Branch (508:26): [True: 24.0k, False: 762k]
  ------------------
  509|  24.0k|                break;
  510|   797k|        }
  511|  62.8k|    } 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|  63.0k|}
sd_ass.c:check_packet_seen:
  439|  63.0k|{
  440|  63.0k|    struct sd_ass_priv *priv = sd->priv;
  441|  63.0k|    int64_t sig = packet->pos >= 0 ? packet->pos
  ------------------
  |  Branch (441:19): [True: 63.0k, False: 0]
  ------------------
  442|  63.0k|                                   : hash_data(packet->buffer, packet->len);
  443|  63.0k|    int a = 0;
  444|  63.0k|    int b = priv->num_seen_packets;
  445|   403k|    while (a < b) {
  ------------------
  |  Branch (445:12): [True: 340k, False: 62.8k]
  ------------------
  446|   340k|        int mid = a + (b - a) / 2;
  447|   340k|        struct seen_packet *seen_packet = &priv->seen_packets[mid];
  448|   340k|        if (sig == seen_packet->sig && packet->pts == seen_packet->pts) {
  ------------------
  |  Branch (448:13): [True: 1.48k, False: 339k]
  |  Branch (448:40): [True: 170, False: 1.31k]
  ------------------
  449|    170|            packet->seen_pos = mid;
  450|    170|            return true;
  451|    170|        }
  452|   340k|        if (sig > seen_packet->sig ||
  ------------------
  |  Branch (452:13): [True: 244k, False: 95.7k]
  ------------------
  453|   246k|            (sig == seen_packet->sig && packet->pts > seen_packet->pts)) {
  ------------------
  |  Branch (453:14): [True: 1.31k, False: 94.4k]
  |  Branch (453:41): [True: 1.31k, False: 0]
  ------------------
  454|   246k|            a = mid + 1;
  455|   246k|        } else {
  456|  94.4k|            b = mid;
  457|  94.4k|        }
  458|   340k|    }
  459|  62.8k|    packet->seen_pos = a;
  460|  62.8k|    MP_TARRAY_INSERT_AT(priv, priv->seen_packets, priv->num_seen_packets, a,
  ------------------
  |  |  115|  62.8k|    do {                                            \
  |  |  116|  62.8k|        size_t at_ = (at);                          \
  |  |  117|  62.8k|        assert(at_ <= (idxvar));                    \
  |  |  118|  62.8k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|  62.8k|    do {                                            \
  |  |  |  |   97|  62.8k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|  62.8k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|  62.8k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|  62.8k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 7.88k, False: 54.9k]
  |  |  |  |  ------------------
  |  |  |  |   99|  62.8k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  7.88k|    do {                                                        \
  |  |  |  |  |  |   89|  7.88k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  7.88k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  7.88k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  7.88k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  7.88k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  7.88k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  7.88k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 7.88k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|  62.8k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 62.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|  62.8k|        memmove((p) + at_ + 1, (p) + at_,           \
  |  |  120|  62.8k|                ((idxvar) - at_) * sizeof((p)[0])); \
  |  |  121|  62.8k|        (idxvar)++;                                 \
  |  |  122|  62.8k|        (p)[at_] = (__VA_ARGS__);                   \
  |  |  123|  62.8k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 62.8k]
  |  |  ------------------
  ------------------
  |  Branch (460:5): [True: 62.8k, False: 0]
  ------------------
  461|  62.8k|                        (struct seen_packet){sig, packet->pts, -1});
  462|  62.8k|    return false;
  463|  62.8k|}
sd_ass.c:filter_and_add:
  371|  62.4k|{
  372|  62.4k|    struct sd_ass_priv *ctx = sd->priv;
  373|  62.4k|    struct demux_packet *orig_pkt = pkt;
  374|  62.4k|    ASS_Track *track = ctx->ass_track;
  375|  62.4k|    int old_n_events = track->n_events;
  376|       |
  377|   122k|    for (int n = 0; n < ctx->num_filters; n++) {
  ------------------
  |  Branch (377:21): [True: 62.4k, False: 60.2k]
  ------------------
  378|  62.4k|        struct sd_filter *ft = ctx->filters[n];
  379|  62.4k|        struct demux_packet *npkt = ft->driver->filter(ft, pkt);
  380|  62.4k|        if (pkt != npkt && pkt != orig_pkt)
  ------------------
  |  Branch (380:13): [True: 4.75k, False: 57.7k]
  |  Branch (380:28): [True: 0, False: 4.75k]
  ------------------
  381|      0|            talloc_free(pkt);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  382|  62.4k|        pkt = npkt;
  383|  62.4k|        if (!pkt)
  ------------------
  |  Branch (383:13): [True: 2.21k, False: 60.2k]
  ------------------
  384|  2.21k|            return;
  385|  62.4k|    }
  386|       |
  387|  60.2k|    ass_process_chunk(ctx->ass_track, pkt->buffer, pkt->len,
  388|  60.2k|                      floor(pkt->pts * 1000 + 1e-6),
  389|  60.2k|                      floor(pkt->duration * 1000 + 1e-6));
  390|  60.2k|    if (pkt != orig_pkt)
  ------------------
  |  Branch (390:9): [True: 2.54k, False: 57.7k]
  ------------------
  391|  2.54k|        talloc_free(pkt);
  ------------------
  |  |   47|  2.54k|#define talloc_free                     ta_free
  ------------------
  392|       |    // the seen and animated state is kept on the original packet
  393|  60.2k|    pkt = orig_pkt;
  394|       |
  395|       |    // This bookkeeping only has any practical use for ASS subs
  396|       |    // over a VO with no video.
  397|  60.2k|    if (!ctx->is_converted) {
  ------------------
  |  Branch (397:9): [True: 0, False: 60.2k]
  ------------------
  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|  60.2k|}
sd_ass.c:reset:
 1008|  12.9k|{
 1009|  12.9k|    struct sd_ass_priv *ctx = sd->priv;
 1010|  12.9k|    if (sd->opts->sub_clear_on_seek || ctx->clear_once) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 12.9k]
  |  Branch (1010:40): [True: 0, False: 12.9k]
  ------------------
 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|  12.9k|    if (ctx->converter)
  ------------------
  |  Branch (1016:9): [True: 11.8k, False: 1.08k]
  ------------------
 1017|  11.8k|        lavc_conv_reset(ctx->converter);
 1018|  12.9k|}
sd_ass.c:enable_output:
  233|  25.8k|{
  234|  25.8k|    struct sd_ass_priv *ctx = sd->priv;
  235|  25.8k|    if (enable == !!ctx->ass_renderer)
  ------------------
  |  Branch (235:9): [True: 12.9k, False: 12.9k]
  ------------------
  236|  12.9k|        return;
  237|  12.9k|    if (ctx->ass_renderer) {
  ------------------
  |  Branch (237:9): [True: 6.45k, False: 6.45k]
  ------------------
  238|  6.45k|        ass_renderer_done(ctx->ass_renderer);
  239|  6.45k|        ctx->ass_renderer = NULL;
  240|  6.45k|    } else {
  241|  6.45k|        ctx->ass_renderer = ass_renderer_init(ctx->ass_library);
  242|       |
  243|  6.45k|        mp_ass_configure_fonts(ctx->ass_renderer, sd->opts->sub_style,
  244|  6.45k|                               sd->global, sd->log);
  245|  6.45k|    }
  246|  12.9k|}
sd_ass.c:uninit:
 1021|  6.45k|{
 1022|  6.45k|    struct sd_ass_priv *ctx = sd->priv;
 1023|       |
 1024|  6.45k|    filters_destroy(sd);
 1025|  6.45k|    if (ctx->converter)
  ------------------
  |  Branch (1025:9): [True: 5.91k, False: 543]
  ------------------
 1026|  5.91k|        lavc_conv_uninit(ctx->converter);
 1027|  6.45k|    assobjects_destroy(sd);
 1028|  6.45k|    talloc_free(ctx->copy_cache);
  ------------------
  |  |   47|  6.45k|#define talloc_free                     ta_free
  ------------------
 1029|  6.45k|}
sd_ass.c:assobjects_destroy:
  294|  6.45k|{
  295|  6.45k|    struct sd_ass_priv *ctx = sd->priv;
  296|       |
  297|  6.45k|    ass_free_track(ctx->ass_track);
  298|  6.45k|    ass_free_track(ctx->shadow_track);
  299|       |    enable_output(sd, false);
  300|  6.45k|    ass_library_done(ctx->ass_library);
  301|  6.45k|}
sd_ass.c:control:
 1070|   981k|{
 1071|   981k|    struct sd_ass_priv *ctx = sd->priv;
 1072|   981k|    switch (cmd) {
 1073|      0|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (1073:5): [True: 0, False: 981k]
  ------------------
 1074|      0|        double *a = arg;
 1075|      0|        long long ts = floor(a[0] * 1000.0 + 1e-6);
 1076|      0|        long long res = ass_step_sub(ctx->ass_track, ts, a[1]);
 1077|      0|        if (!res)
  ------------------
  |  Branch (1077:13): [True: 0, False: 0]
  ------------------
 1078|      0|            return false;
 1079|       |        // Try to account for overlapping durations
 1080|      0|        a[0] += res / 1000.0 + SUB_SEEK_OFFSET;
  ------------------
  |  |    9|      0|#define SUB_SEEK_OFFSET 0.01
  ------------------
 1081|      0|        return true;
 1082|      0|    }
 1083|   496k|    case SD_CTRL_SET_ANIMATED_CHECK:
  ------------------
  |  Branch (1083:5): [True: 496k, False: 485k]
  ------------------
 1084|   496k|        ctx->check_animated = *(bool *)arg;
 1085|   496k|        return CONTROL_OK;
  ------------------
  |  |   95|   496k|#define CONTROL_OK 1
  ------------------
 1086|      0|    case SD_CTRL_RESET_SOFT:
  ------------------
  |  Branch (1086:5): [True: 0, False: 981k]
  ------------------
 1087|      0|        ctx->clear_once = true;
 1088|      0|        reset(sd);
 1089|      0|        return CONTROL_OK;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
 1090|   485k|    case SD_CTRL_SET_VIDEO_PARAMS:
  ------------------
  |  Branch (1090:5): [True: 485k, False: 496k]
  ------------------
 1091|   485k|        ctx->video_params = *(struct mp_image_params *)arg;
 1092|   485k|        return CONTROL_OK;
  ------------------
  |  |   95|   485k|#define CONTROL_OK 1
  ------------------
 1093|      0|    case SD_CTRL_UPDATE_OPTS: {
  ------------------
  |  Branch (1093:5): [True: 0, False: 981k]
  ------------------
 1094|      0|        uint64_t flags = *(uint64_t *)arg;
 1095|      0|        if (flags & UPDATE_SUB_FILT) {
  ------------------
  |  |  443|      0|#define UPDATE_SUB_FILT         (UINT64_C(1) << 1)   // subtitle filter options
  ------------------
  |  Branch (1095:13): [True: 0, False: 0]
  ------------------
 1096|      0|            filters_destroy(sd);
 1097|      0|            filters_init(sd);
 1098|      0|            ctx->clear_once = true; // allow reloading on seeks
 1099|      0|            reset(sd);
 1100|      0|        }
 1101|      0|        if (flags & UPDATE_SUB_HARD) {
  ------------------
  |  |  455|      0|#define UPDATE_SUB_HARD         (UINT64_C(1) << 13)  // subtitle opts. that need full reinit
  ------------------
  |  Branch (1101:13): [True: 0, False: 0]
  ------------------
 1102|       |            // ass_track will be recreated, so clear duplicate cache
 1103|      0|            ctx->clear_once = true;
 1104|      0|            reset(sd);
 1105|      0|            assobjects_destroy(sd);
 1106|      0|            assobjects_init(sd);
 1107|      0|        }
 1108|      0|        ctx->ass_configured = false; // ass always needs to be reconfigured
 1109|      0|        return CONTROL_OK;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
 1110|      0|    }
 1111|      0|    default:
  ------------------
  |  Branch (1111:5): [True: 0, False: 981k]
  ------------------
 1112|      0|        return CONTROL_UNKNOWN;
  ------------------
  |  |   98|      0|#define CONTROL_UNKNOWN -1
  ------------------
 1113|   981k|    }
 1114|   981k|}
sd_ass.c:get_bitmaps:
  740|   161k|{
  741|   161k|    struct sd_ass_priv *ctx = sd->priv;
  742|   161k|    struct mp_subtitle_opts *opts = sd->opts;
  743|   161k|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  744|   161k|    bool no_ass = !opts->ass_enabled ||
  ------------------
  |  Branch (744:19): [True: 0, False: 161k]
  ------------------
  745|   161k|        shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_STRIP;
  ------------------
  |  Branch (745:9): [True: 0, False: 161k]
  ------------------
  746|   161k|    bool converted = (ctx->is_converted && !lavc_conv_is_styled(ctx->converter)) || no_ass;
  ------------------
  |  Branch (746:23): [True: 147k, False: 13.5k]
  |  Branch (746:44): [True: 147k, False: 0]
  |  Branch (746:85): [True: 0, False: 13.5k]
  ------------------
  747|   161k|    ASS_Track *track = no_ass ? ctx->shadow_track : ctx->ass_track;
  ------------------
  |  Branch (747:24): [True: 0, False: 161k]
  ------------------
  748|   161k|    ASS_Renderer *renderer = ctx->ass_renderer;
  749|   161k|    struct sub_bitmaps *res = &(struct sub_bitmaps){0};
  750|       |
  751|       |    // Always update the osd_res
  752|   161k|    struct mp_osd_res old_osd = ctx->osd;
  753|   161k|    ctx->osd = dim;
  754|       |
  755|   161k|    if (pts == MP_NOPTS_VALUE || !renderer)
  ------------------
  |  |   39|   322k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (755:9): [True: 0, False: 161k]
  |  Branch (755:34): [True: 0, False: 161k]
  ------------------
  756|      0|        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|   161k|    if (opts->sub_forced_events_only)
  ------------------
  |  Branch (761:9): [True: 0, False: 161k]
  ------------------
  762|      0|        goto done;
  763|       |
  764|   161k|    double scale = dim.display_par;
  765|   161k|    if (!converted && (!shared_opts->ass_style_override[sd->order] ||
  ------------------
  |  Branch (765:9): [True: 13.5k, False: 147k]
  |  Branch (765:24): [True: 0, False: 13.5k]
  ------------------
  766|  13.5k|                       opts->ass_use_video_data >= 1))
  ------------------
  |  Branch (766:24): [True: 13.5k, False: 0]
  ------------------
  767|  13.5k|    {
  768|       |        // Let's factor in video PAR for vsfilter compatibility:
  769|  13.5k|        double par = opts->ass_video_aspect > 0 ?
  ------------------
  |  Branch (769:22): [True: 0, False: 13.5k]
  ------------------
  770|      0|                opts->ass_video_aspect :
  771|  13.5k|                ctx->video_params.p_w / (double)ctx->video_params.p_h;
  772|  13.5k|        if (isnormal(par))
  ------------------
  |  Branch (772:13): [True: 13.0k, False: 543]
  ------------------
  773|  13.0k|            scale *= par;
  774|  13.5k|    }
  775|   161k|    if (!ctx->ass_configured || !osd_res_equals(old_osd, ctx->osd)) {
  ------------------
  |  Branch (775:9): [True: 6.45k, False: 154k]
  |  Branch (775:33): [True: 0, False: 154k]
  ------------------
  776|  6.45k|        configure_ass(sd, &dim, converted, track);
  777|  6.45k|        ctx->ass_configured = true;
  778|  6.45k|    }
  779|   161k|    ass_set_pixel_aspect(renderer, scale);
  780|   161k|    if (!converted && (!shared_opts->ass_style_override[sd->order] ||
  ------------------
  |  Branch (780:9): [True: 13.5k, False: 147k]
  |  Branch (780:24): [True: 0, False: 13.5k]
  ------------------
  781|  13.5k|                       opts->ass_use_video_data >= 2))
  ------------------
  |  Branch (781:24): [True: 13.5k, False: 0]
  ------------------
  782|  13.5k|    {
  783|  13.5k|        ass_set_storage_size(renderer, ctx->video_params.w, ctx->video_params.h);
  784|   147k|    } else {
  785|   147k|        ass_set_storage_size(renderer, 0, 0);
  786|   147k|    }
  787|   161k|    long long ts = find_timestamp(sd, pts);
  788|       |
  789|   161k|    if (no_ass)
  ------------------
  |  Branch (789:9): [True: 0, False: 161k]
  ------------------
  790|      0|        fill_plaintext(sd, pts);
  791|       |
  792|   161k|    int changed;
  793|   161k|    ASS_Image *imgs = ass_render_frame(renderer, track, ts, &changed);
  794|   161k|    mp_sub_packer_pack_ass(ctx->packer, &imgs, 1, changed, !converted, format, res);
  795|       |
  796|   161k|done:
  797|       |    // mangle_colors() modifies the color field, so copy the thing _before_.
  798|   161k|    res = sub_bitmaps_copy(&ctx->copy_cache, res);
  799|       |
  800|   161k|    if (!converted && res)
  ------------------
  |  Branch (800:9): [True: 13.5k, False: 147k]
  |  Branch (800:23): [True: 0, False: 13.5k]
  ------------------
  801|      0|        mangle_colors(sd, res);
  802|       |
  803|   161k|    return res;
  804|   161k|}
sd_ass.c:configure_ass:
  537|  6.45k|{
  538|  6.45k|    struct mp_subtitle_opts *opts = sd->opts;
  539|  6.45k|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  540|  6.45k|    struct sd_ass_priv *ctx = sd->priv;
  541|  6.45k|    ASS_Renderer *priv = ctx->ass_renderer;
  542|       |
  543|  6.45k|    ass_set_frame_size(priv, dim->w, dim->h);
  544|  6.45k|    ass_set_margins(priv, dim->mt, dim->mb, dim->ml, dim->mr);
  545|       |
  546|  6.45k|    bool set_use_margins = false;
  547|  6.45k|    float set_sub_pos = 0.0f;
  548|  6.45k|    float set_line_spacing = 0;
  549|  6.45k|    float set_font_scale = 1;
  550|  6.45k|    int set_hinting = 0;
  551|  6.45k|    bool set_scale_with_window = false;
  552|  6.45k|    bool set_scale_by_window = true;
  553|  6.45k|    bool total_override = false;
  554|       |
  555|       |    // With forced overrides, apply the --sub-* specific options
  556|  6.45k|    if (converted || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_FORCE) {
  ------------------
  |  Branch (556:9): [True: 5.91k, False: 543]
  |  Branch (556:22): [True: 0, False: 543]
  ------------------
  557|  5.91k|        set_scale_with_window = opts->sub_scale_with_window;
  558|  5.91k|        set_use_margins = opts->sub_use_margins;
  559|  5.91k|        set_scale_by_window = opts->sub_scale_by_window;
  560|  5.91k|        total_override = true;
  561|  5.91k|    } else {
  562|    543|        set_scale_with_window = opts->ass_scale_with_window;
  563|    543|        set_use_margins = opts->ass_use_margins;
  564|    543|    }
  565|  6.45k|    if (converted || shared_opts->ass_style_override[sd->order]) {
  ------------------
  |  Branch (565:9): [True: 5.91k, False: 543]
  |  Branch (565:22): [True: 543, False: 0]
  ------------------
  566|  6.45k|        set_sub_pos = 100.0f - shared_opts->sub_pos[sd->order];
  567|  6.45k|        set_line_spacing = opts->sub_line_spacing;
  568|  6.45k|        set_hinting = opts->sub_hinting;
  569|  6.45k|    }
  570|  6.45k|    if (total_override || shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE) {
  ------------------
  |  Branch (570:9): [True: 5.91k, False: 543]
  |  Branch (570:27): [True: 543, False: 0]
  ------------------
  571|  6.45k|        set_font_scale = shared_opts->sub_scale[sd->order];
  572|  6.45k|    }
  573|  6.45k|    if (set_scale_with_window) {
  ------------------
  |  Branch (573:9): [True: 5.91k, False: 543]
  ------------------
  574|  5.91k|        set_font_scale *= dim->h / MPMAX(get_libass_scale_height(dim, set_use_margins), 1);
  ------------------
  |  |   44|  5.91k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 5.91k, False: 0]
  |  |  ------------------
  ------------------
  575|  5.91k|    }
  576|  6.45k|    if (!set_scale_by_window) {
  ------------------
  |  Branch (576:9): [True: 0, False: 6.45k]
  ------------------
  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|  6.45k|    ass_set_use_margins(priv, set_use_margins);
  582|  6.45k|    ass_set_line_position(priv, set_sub_pos);
  583|  6.45k|    ass_set_shaper(priv, opts->sub_shaper);
  584|  6.45k|    int set_force_flags = 0;
  585|  6.45k|    if (total_override) {
  ------------------
  |  Branch (585:9): [True: 5.91k, False: 543]
  ------------------
  586|  5.91k|        set_force_flags |= ASS_OVERRIDE_BIT_FONT_NAME
  587|  5.91k|                            | ASS_OVERRIDE_BIT_FONT_SIZE_FIELDS
  588|  5.91k|                            | ASS_OVERRIDE_BIT_COLORS
  589|  5.91k|                            | ASS_OVERRIDE_BIT_BORDER;
  590|  5.91k|        if (!opts->sub_scale_signs)
  ------------------
  |  Branch (590:13): [True: 5.91k, False: 0]
  ------------------
  591|  5.91k|            set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE;
  592|  5.91k|#if LIBASS_VERSION >= 0x01703020
  593|  5.91k|        set_force_flags |= ASS_OVERRIDE_BIT_BLUR;
  594|  5.91k|#endif
  595|  5.91k|    }
  596|  6.45k|    if (shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_SCALE &&
  ------------------
  |  Branch (596:9): [True: 6.45k, False: 0]
  ------------------
  597|  6.45k|        !opts->sub_scale_signs)
  ------------------
  |  Branch (597:9): [True: 6.45k, False: 0]
  ------------------
  598|  6.45k|        set_force_flags |= ASS_OVERRIDE_BIT_SELECTIVE_FONT_SCALE;
  599|  6.45k|    if (converted)
  ------------------
  |  Branch (599:9): [True: 5.91k, False: 543]
  ------------------
  600|  5.91k|        set_force_flags |= ASS_OVERRIDE_BIT_ALIGNMENT;
  601|  6.45k|#if LIBASS_VERSION >= 0x01306000
  602|  6.45k|    if ((converted || shared_opts->ass_style_override[sd->order]) && opts->ass_justify)
  ------------------
  |  Branch (602:10): [True: 5.91k, False: 543]
  |  Branch (602:23): [True: 543, False: 0]
  |  Branch (602:70): [True: 0, False: 6.45k]
  ------------------
  603|      0|        set_force_flags |= ASS_OVERRIDE_BIT_JUSTIFY;
  604|  6.45k|#endif
  605|  6.45k|    ass_set_selective_style_override_enabled(priv, set_force_flags);
  606|  6.45k|    ASS_Style style = {0};
  607|  6.45k|    mp_ass_set_style(&style, MP_ASS_FONT_PLAYRESY, opts->sub_style);
  ------------------
  |  |   32|  6.45k|#define MP_ASS_FONT_PLAYRESY 288
  ------------------
  608|  6.45k|    ass_set_selective_style_override(priv, &style);
  609|  6.45k|    free(style.FontName);
  610|  6.45k|    if (converted && track->default_style < track->n_styles) {
  ------------------
  |  Branch (610:9): [True: 5.91k, False: 543]
  |  Branch (610:22): [True: 5.91k, False: 0]
  ------------------
  611|  5.91k|        mp_ass_set_style(track->styles + track->default_style,
  612|  5.91k|                         track->PlayResY, opts->sub_style);
  613|  5.91k|    }
  614|  6.45k|    ass_set_font_scale(priv, set_font_scale);
  615|  6.45k|    ass_set_hinting(priv, set_hinting);
  616|  6.45k|    ass_set_line_spacing(priv, set_line_spacing);
  617|  6.45k|#if LIBASS_VERSION >= 0x01600010
  618|  6.45k|    if (converted) {
  ------------------
  |  Branch (618:9): [True: 5.91k, False: 543]
  ------------------
  619|  5.91k|        ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1);
  620|  5.91k|        if (!opts->sub_vsfilter_bidi_compat) {
  ------------------
  |  Branch (620:13): [True: 5.91k, False: 0]
  ------------------
  621|  17.7k|            for (int n = 0; n < track->n_styles; n++) {
  ------------------
  |  Branch (621:29): [True: 11.8k, False: 5.91k]
  ------------------
  622|  11.8k|                track->styles[n].Encoding = -1;
  623|  11.8k|            }
  624|  5.91k|            ass_track_set_feature(track, ASS_FEATURE_BIDI_BRACKETS, 1);
  625|  5.91k|            ass_track_set_feature(track, ASS_FEATURE_WHOLE_TEXT_LAYOUT, 1);
  626|  5.91k|        }
  627|  5.91k|    }
  628|  6.45k|#endif
  629|  6.45k|    if (converted) {
  ------------------
  |  Branch (629:9): [True: 5.91k, False: 543]
  ------------------
  630|  5.91k|        bool override_playres = true;
  631|  5.91k|        char **ass_style_override_list = opts->ass_style_override_list;
  632|  5.91k|        for (int i = 0; ass_style_override_list && ass_style_override_list[i]; i++) {
  ------------------
  |  Branch (632:25): [True: 0, False: 5.91k]
  |  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|  5.91k|        if (override_playres) {
  ------------------
  |  Branch (646:13): [True: 5.91k, False: 0]
  ------------------
  647|  5.91k|            int vidw = dim->w - (dim->ml + dim->mr);
  648|  5.91k|            int vidh = dim->h - (dim->mt + dim->mb);
  649|  5.91k|            track->PlayResX = track->PlayResY * (double)vidw / MPMAX(vidh, 1);
  ------------------
  |  |   44|  5.91k|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 5.91k, False: 0]
  |  |  ------------------
  ------------------
  650|       |            // ffmpeg and mpv use a default PlayResX of 384 when it is not known,
  651|       |            // this comes from VSFilter.
  652|  5.91k|            double fix_margins = track->PlayResX / (double)MP_ASS_FONT_PLAYRESX;
  ------------------
  |  |   31|  5.91k|#define MP_ASS_FONT_PLAYRESX 384
  ------------------
  653|  17.7k|            for (int n = 0; n < track->n_styles; n++) {
  ------------------
  |  Branch (653:29): [True: 11.8k, False: 5.91k]
  ------------------
  654|  11.8k|                track->styles[n].MarginL = lrint(track->styles[n].MarginL * fix_margins);
  655|  11.8k|                track->styles[n].MarginR = lrint(track->styles[n].MarginR * fix_margins);
  656|  11.8k|                track->styles[n].MarginV = lrint(track->styles[n].MarginV * set_font_scale);
  657|  11.8k|            }
  658|  5.91k|        }
  659|  5.91k|    }
  660|  6.45k|}
sd_ass.c:get_libass_scale_height:
  526|  11.8k|{
  527|  11.8k|    float vidw = dim->w - (dim->ml + dim->mr);
  528|  11.8k|    float vidh = dim->h - (dim->mt + dim->mb);
  529|  11.8k|    if (!use_margins || vidw < 1.0)
  ------------------
  |  Branch (529:9): [True: 0, False: 11.8k]
  |  Branch (529:25): [True: 0, False: 11.8k]
  ------------------
  530|      0|        return vidh;
  531|  11.8k|    else
  532|  11.8k|        return MPMIN(dim->h, dim->w / vidw * vidh);
  ------------------
  |  |   45|  11.8k|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 11.8k]
  |  |  ------------------
  ------------------
  533|  11.8k|}
sd_ass.c:find_timestamp:
  673|   161k|{
  674|   161k|    struct sd_ass_priv *priv = sd->priv;
  675|   161k|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|   161k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (675:9): [True: 0, False: 161k]
  ------------------
  676|      0|        return 0;
  677|       |
  678|   161k|    long long ts = floor(pts * 1000 + 1e-6);
  679|       |
  680|   161k|    if (!sd->opts->sub_fix_timing ||
  ------------------
  |  Branch (680:9): [True: 161k, False: 0]
  ------------------
  681|      0|        sd->shared_opts->ass_style_override[sd->order] == ASS_STYLE_OVERRIDE_NONE)
  ------------------
  |  Branch (681:9): [True: 0, False: 0]
  ------------------
  682|   161k|        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_lavc.c:init:
   82|  6.68k|{
   83|  6.68k|    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|  6.68k|    switch (cid) {
   87|      0|    case AV_CODEC_ID_DVB_SUBTITLE:
  ------------------
  |  Branch (87:5): [True: 0, False: 6.68k]
  ------------------
   88|      0|    case AV_CODEC_ID_DVB_TELETEXT:
  ------------------
  |  Branch (88:5): [True: 0, False: 6.68k]
  ------------------
   89|      0|    case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
  ------------------
  |  Branch (89:5): [True: 0, False: 6.68k]
  ------------------
   90|      0|    case AV_CODEC_ID_XSUB:
  ------------------
  |  Branch (90:5): [True: 0, False: 6.68k]
  ------------------
   91|    207|    case AV_CODEC_ID_DVD_SUBTITLE:
  ------------------
  |  Branch (91:5): [True: 207, False: 6.47k]
  ------------------
   92|    207|    case AV_CODEC_ID_ARIB_CAPTION:
  ------------------
  |  Branch (92:5): [True: 0, False: 6.68k]
  ------------------
   93|    207|        break;
   94|  6.47k|    default:
  ------------------
  |  Branch (94:5): [True: 6.47k, False: 207]
  ------------------
   95|  6.47k|        return -1;
   96|  6.68k|    }
   97|       |
   98|    207|    struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv);
  ------------------
  |  |   27|    207|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    207|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    207|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   99|    207|    AVCodecContext *ctx = NULL;
  100|    207|    const AVCodec *sub_codec = avcodec_find_decoder(cid);
  101|    207|    if (!sub_codec)
  ------------------
  |  Branch (101:9): [True: 0, False: 207]
  ------------------
  102|      0|        goto error_probe;
  103|    207|    ctx = avcodec_alloc_context3(sub_codec);
  104|    207|    if (!ctx)
  ------------------
  |  Branch (104:9): [True: 0, False: 207]
  ------------------
  105|      0|        goto error_probe;
  106|       |
  107|    207|    mp_set_avopts(sd->log, ctx, sd->opts->sub_avopts);
  108|       |
  109|    207|    switch (cid) {
  ------------------
  |  Branch (109:13): [True: 0, False: 207]
  ------------------
  110|      0|    case AV_CODEC_ID_DVB_TELETEXT: {
  ------------------
  |  Branch (110:5): [True: 0, False: 207]
  ------------------
  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: 207]
  ------------------
  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|    207|    }
  128|       |
  129|    207|    MP_VERBOSE(sd, "Using subtitle decoder %s\n", sub_codec->name);
  ------------------
  |  |   92|    207|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|    207|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  130|       |
  131|    207|    priv->avpkt = av_packet_alloc();
  132|    207|    priv->codec = sd->codec;
  133|    207|    if (!priv->avpkt)
  ------------------
  |  Branch (133:9): [True: 0, False: 207]
  ------------------
  134|      0|        goto error;
  135|    207|    if (mp_set_avctx_codec_headers(ctx, sd->codec) < 0)
  ------------------
  |  Branch (135:9): [True: 0, False: 207]
  ------------------
  136|      0|        goto error;
  137|    207|    priv->pkt_timebase = mp_get_codec_timebase(sd->codec);
  138|    207|    ctx->pkt_timebase = priv->pkt_timebase;
  139|    207|    if (avcodec_open2(ctx, sub_codec, NULL) < 0)
  ------------------
  |  Branch (139:9): [True: 0, False: 207]
  ------------------
  140|      0|        goto error;
  141|    207|    priv->avctx = ctx;
  142|    207|    sd->priv = priv;
  143|    207|    priv->displayed_id = -1;
  144|    207|    priv->current_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    207|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  145|    207|    priv->packer = talloc_zero(priv, struct bitmap_packer);
  ------------------
  |  |   27|    207|#define talloc_zero                     ta_xznew
  |  |  ------------------
  |  |  |  |  134|    207|#define ta_xznew(...)                   ta_oom_g(ta_znew(__VA_ARGS__))
  |  |  |  |  ------------------
  |  |  |  |  |  |  182|    207|#define ta_oom_g(ptr) (TA_TYPEOF(ptr))ta_oom_p(ptr)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  146|    207|    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|}
sd_lavc.c:decode:
  369|      1|{
  370|      1|    struct mp_subtitle_opts *opts = sd->opts;
  371|      1|    struct sd_lavc_priv *priv = sd->priv;
  372|      1|    AVCodecContext *ctx = priv->avctx;
  373|      1|    double pts = packet->pts;
  374|      1|    double endpts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|      1|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  375|      1|    AVSubtitle sub;
  376|       |
  377|      1|    if (pts == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      1|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (377:9): [True: 0, False: 1]
  ------------------
  378|      1|        MP_WARN(sd, "Subtitle with unknown start time.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  379|       |
  380|      1|    mp_set_av_packet(priv->avpkt, packet, &priv->pkt_timebase);
  381|       |
  382|      1|    if (ctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
  ------------------
  |  Branch (382:9): [True: 0, False: 1]
  ------------------
  383|      0|        if (!opts->teletext_page) {
  ------------------
  |  Branch (383:13): [True: 0, False: 0]
  ------------------
  384|      0|            av_opt_set(ctx, "txt_page", "subtitle", AV_OPT_SEARCH_CHILDREN);
  385|      0|        } else if (opts->teletext_page == -1) {
  ------------------
  |  Branch (385:20): [True: 0, False: 0]
  ------------------
  386|      0|            av_opt_set(ctx, "txt_page", "*", AV_OPT_SEARCH_CHILDREN);
  387|      0|        } else {
  388|      0|            char page[4];
  389|      0|            snprintf(page, sizeof(page), "%d", opts->teletext_page);
  390|      0|            av_opt_set(ctx, "txt_page", page, AV_OPT_SEARCH_CHILDREN);
  391|      0|        }
  392|      0|    }
  393|       |
  394|      1|    int got_sub;
  395|      1|    int res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, priv->avpkt);
  396|      1|    if (res < 0 || !got_sub)
  ------------------
  |  Branch (396:9): [True: 0, False: 1]
  |  Branch (396:20): [True: 1, False: 0]
  ------------------
  397|      1|        return;
  398|       |
  399|      0|    mp_codec_info_from_av(ctx, priv->codec);
  400|       |
  401|      0|    packet->sub_duration = sub.end_display_time;
  402|       |
  403|      0|    if (sub.pts != AV_NOPTS_VALUE)
  ------------------
  |  Branch (403:9): [True: 0, False: 0]
  ------------------
  404|      0|        pts = sub.pts / (double)AV_TIME_BASE;
  405|       |
  406|      0|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (406:9): [True: 0, False: 0]
  ------------------
  407|      0|        if (sub.end_display_time > sub.start_display_time &&
  ------------------
  |  Branch (407:13): [True: 0, False: 0]
  ------------------
  408|      0|            sub.end_display_time != UINT32_MAX)
  ------------------
  |  Branch (408:13): [True: 0, False: 0]
  ------------------
  409|      0|        {
  410|      0|            endpts = pts + sub.end_display_time / 1000.0;
  411|      0|        }
  412|      0|        pts += sub.start_display_time / 1000.0;
  413|       |
  414|       |        // set end time of previous sub
  415|      0|        struct sub *prev = &priv->subs[0];
  416|      0|        if (prev->valid) {
  ------------------
  |  Branch (416:13): [True: 0, False: 0]
  ------------------
  417|      0|            if (prev->endpts == MP_NOPTS_VALUE || prev->endpts > pts)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (417:17): [True: 0, False: 0]
  |  Branch (417:51): [True: 0, False: 0]
  ------------------
  418|      0|                prev->endpts = pts;
  419|       |
  420|      0|            if (opts->sub_fix_timing && pts - prev->endpts <= opts->sub_fix_timing_threshold / 1000.0)
  ------------------
  |  Branch (420:17): [True: 0, False: 0]
  |  Branch (420:41): [True: 0, False: 0]
  ------------------
  421|      0|                prev->endpts = pts;
  422|       |
  423|      0|            for (int n = 0; n < priv->num_seekpoints; n++) {
  ------------------
  |  Branch (423:29): [True: 0, False: 0]
  ------------------
  424|      0|                if (priv->seekpoints[n].pts == prev->pts) {
  ------------------
  |  Branch (424:21): [True: 0, False: 0]
  ------------------
  425|      0|                    priv->seekpoints[n].endpts = prev->endpts;
  426|      0|                    break;
  427|      0|                }
  428|      0|            }
  429|      0|        }
  430|       |
  431|       |        // This subtitle packet only signals the end of subtitle display.
  432|      0|        if (!sub.num_rects) {
  ------------------
  |  Branch (432:13): [True: 0, False: 0]
  ------------------
  433|      0|            avsubtitle_free(&sub);
  434|      0|            return;
  435|      0|        }
  436|      0|    }
  437|       |
  438|      0|    alloc_sub(priv);
  439|      0|    struct sub *current = &priv->subs[0];
  440|       |
  441|      0|    current->valid = true;
  442|      0|    current->pts = pts;
  443|      0|    current->endpts = endpts;
  444|      0|    current->avsub = sub;
  445|       |
  446|      0|    read_sub_bitmaps(sd, current);
  447|       |
  448|      0|    if (pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (448:9): [True: 0, False: 0]
  ------------------
  449|      0|        for (int n = 0; n < priv->num_seekpoints; n++) {
  ------------------
  |  Branch (449:25): [True: 0, False: 0]
  ------------------
  450|      0|            if (priv->seekpoints[n].pts == pts)
  ------------------
  |  Branch (450:17): [True: 0, False: 0]
  ------------------
  451|      0|                goto skip;
  452|      0|        }
  453|       |        // Set arbitrary limit as safe-guard against insane files.
  454|      0|        if (priv->num_seekpoints >= 10000)
  ------------------
  |  Branch (454:13): [True: 0, False: 0]
  ------------------
  455|      0|            MP_TARRAY_REMOVE_AT(priv->seekpoints, priv->num_seekpoints, 0);
  ------------------
  |  |  143|      0|    do {                                            \
  |  |  144|      0|        size_t at_ = (at);                          \
  |  |  145|      0|        assert(at_ < (idxvar));                     \
  |  |  146|      0|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|      0|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|      0|        (idxvar)--;                                 \
  |  |  149|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (455:13): [True: 0, False: 0]
  ------------------
  456|      0|        MP_TARRAY_APPEND(priv, priv->seekpoints, priv->num_seekpoints,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  457|      0|                         (struct seekpoint){.pts = pts, .endpts = endpts});
  458|      0|        skip: ;
  459|      0|    }
  460|      0|}
sd_lavc.c:clear_sub:
  158|  2.48k|{
  159|  2.48k|    sub->count = 0;
  160|  2.48k|    sub->pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.48k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  161|  2.48k|    sub->endpts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|  2.48k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  162|  2.48k|    if (sub->valid)
  ------------------
  |  Branch (162:9): [True: 0, False: 2.48k]
  ------------------
  163|      0|        avsubtitle_free(&sub->avsub);
  164|       |    sub->valid = false;
  165|  2.48k|}
sd_lavc.c:reset:
  665|    414|{
  666|    414|    struct sd_lavc_priv *priv = sd->priv;
  667|       |
  668|  2.07k|    for (int n = 0; n < MAX_QUEUE; n++)
  ------------------
  |  |   38|  2.07k|#define MAX_QUEUE 4
  ------------------
  |  Branch (668:21): [True: 1.65k, False: 414]
  ------------------
  669|  1.65k|        clear_sub(&priv->subs[n]);
  670|       |    // lavc might not do this right for all codecs; may need close+reopen
  671|    414|    avcodec_flush_buffers(priv->avctx);
  672|       |
  673|    414|    priv->current_pts = MP_NOPTS_VALUE;
  ------------------
  |  |   39|    414|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  674|    414|}
sd_lavc.c:uninit:
  677|    207|{
  678|    207|    struct sd_lavc_priv *priv = sd->priv;
  679|       |
  680|  1.03k|    for (int n = 0; n < MAX_QUEUE; n++)
  ------------------
  |  |   38|  1.03k|#define MAX_QUEUE 4
  ------------------
  |  Branch (680:21): [True: 828, False: 207]
  ------------------
  681|    828|        clear_sub(&priv->subs[n]);
  682|    207|    avcodec_free_context(&priv->avctx);
  683|    207|    mp_free_av_packet(&priv->avpkt);
  684|    207|    talloc_free(priv);
  ------------------
  |  |   47|    207|#define talloc_free                     ta_free
  ------------------
  685|    207|}
sd_lavc.c:accepts_packet:
  633|  16.1k|{
  634|  16.1k|    struct sd_lavc_priv *priv = sd->priv;
  635|       |
  636|  16.1k|    double pts = priv->current_pts;
  637|  16.1k|    if (min_pts != MP_NOPTS_VALUE) {
  ------------------
  |  |   39|  16.1k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (637:9): [True: 15.6k, False: 499]
  ------------------
  638|       |        // guard against bogus rendering PTS in the future.
  639|  15.6k|        if (pts == MP_NOPTS_VALUE || min_pts < pts)
  ------------------
  |  |   39|  31.2k|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (639:13): [True: 0, False: 15.6k]
  |  Branch (639:38): [True: 6, False: 15.6k]
  ------------------
  640|      6|            pts = min_pts;
  641|       |        // Heuristic: we assume rendering cannot lag behind more than 1 second
  642|       |        // behind decoding.
  643|  15.6k|        if (pts + 1 < min_pts)
  ------------------
  |  Branch (643:13): [True: 0, False: 15.6k]
  ------------------
  644|      0|            pts = min_pts;
  645|  15.6k|    }
  646|       |
  647|  16.1k|    int last_needed = -1;
  648|  80.7k|    for (int n = 0; n < MAX_QUEUE; n++) {
  ------------------
  |  |   38|  80.7k|#define MAX_QUEUE 4
  ------------------
  |  Branch (648:21): [True: 64.5k, False: 16.1k]
  ------------------
  649|  64.5k|        struct sub *sub = &priv->subs[n];
  650|  64.5k|        if (!sub->valid)
  ------------------
  |  Branch (650:13): [True: 64.5k, False: 0]
  ------------------
  651|  64.5k|            continue;
  652|      0|        if (pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (652:13): [True: 0, False: 0]
  ------------------
  653|      0|            ((sub->pts == MP_NOPTS_VALUE || sub->pts >= pts) ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (653:15): [True: 0, False: 0]
  |  Branch (653:45): [True: 0, False: 0]
  ------------------
  654|      0|             (sub->endpts == MP_NOPTS_VALUE || pts < sub->endpts)))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (654:15): [True: 0, False: 0]
  |  Branch (654:48): [True: 0, False: 0]
  ------------------
  655|      0|        {
  656|      0|            last_needed = n;
  657|      0|        }
  658|      0|    }
  659|       |    // We can accept a packet if it wouldn't overflow the fixed subtitle queue.
  660|       |    // We assume that get_bitmaps() never decreases the PTS.
  661|  16.1k|    return last_needed + 1 < MAX_QUEUE;
  ------------------
  |  |   38|  16.1k|#define MAX_QUEUE 4
  ------------------
  662|  16.1k|}
sd_lavc.c:control:
  748|  31.8k|{
  749|  31.8k|    struct sd_lavc_priv *priv = sd->priv;
  750|  31.8k|    switch (cmd) {
  751|      0|    case SD_CTRL_SUB_STEP: {
  ------------------
  |  Branch (751:5): [True: 0, False: 31.8k]
  ------------------
  752|      0|        double *a = arg;
  753|      0|        double res = step_sub(sd, a[0], a[1]);
  754|      0|        if (res == MP_NOPTS_VALUE)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (754:13): [True: 0, False: 0]
  ------------------
  755|      0|            return false;
  756|      0|        a[0] = res;
  757|      0|        return true;
  758|      0|    }
  759|  15.7k|    case SD_CTRL_SET_VIDEO_PARAMS:
  ------------------
  |  Branch (759:5): [True: 15.7k, False: 16.1k]
  ------------------
  760|  15.7k|        priv->video_params = *(struct mp_image_params *)arg;
  761|  15.7k|        return CONTROL_OK;
  ------------------
  |  |   95|  15.7k|#define CONTROL_OK 1
  ------------------
  762|      0|    case SD_CTRL_APPLY_DVDNAV: {
  ------------------
  |  Branch (762:5): [True: 0, False: 31.8k]
  ------------------
  763|      0|        const struct stream_nav_state *nav = arg;
  764|      0|        bool menu_closed = priv->menu_active && !nav->menu_active;
  ------------------
  |  Branch (764:28): [True: 0, False: 0]
  |  Branch (764:49): [True: 0, False: 0]
  ------------------
  765|      0|        bool changed = priv->hli_change_id != nav->change_id;
  766|      0|        priv->menu_active = nav->menu_active;
  767|      0|        priv->hl = nav->hl;
  768|      0|        priv->hli_change_id = nav->change_id;
  769|       |        // Don't let menu subpictures leak into title playback.
  770|      0|        if (menu_closed) {
  ------------------
  |  Branch (770:13): [True: 0, False: 0]
  ------------------
  771|      0|            for (int n = 0; n < MAX_QUEUE; n++)
  ------------------
  |  |   38|      0|#define MAX_QUEUE 4
  ------------------
  |  Branch (771:29): [True: 0, False: 0]
  ------------------
  772|      0|                clear_sub(&priv->subs[n]);
  773|      0|        }
  774|       |        // Re-render any decoded subtitles, after style update.
  775|      0|        if (changed)
  ------------------
  |  Branch (775:13): [True: 0, False: 0]
  ------------------
  776|      0|            rerender_queued_subs(sd);
  777|      0|        return CONTROL_OK;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
  778|      0|    }
  779|  16.1k|    default:
  ------------------
  |  Branch (779:5): [True: 16.1k, False: 15.7k]
  ------------------
  780|  16.1k|        return CONTROL_UNKNOWN;
  ------------------
  |  |   98|  16.1k|#define CONTROL_UNKNOWN -1
  ------------------
  781|  31.8k|    }
  782|  31.8k|}
sd_lavc.c:get_bitmaps:
  485|  5.17k|{
  486|  5.17k|    struct sd_lavc_priv *priv = sd->priv;
  487|  5.17k|    struct mp_subtitle_opts *opts = sd->opts;
  488|  5.17k|    struct mp_subtitle_shared_opts *shared_opts = sd->shared_opts;
  489|       |
  490|  5.17k|    priv->current_pts = pts;
  491|       |
  492|  5.17k|    struct sub *current = get_current(priv, pts);
  493|       |
  494|  5.17k|    if (!current)
  ------------------
  |  Branch (494:9): [True: 5.17k, False: 0]
  ------------------
  495|  5.17k|        return NULL;
  496|       |
  497|      0|    MP_TARRAY_GROW(priv, priv->outbitmaps, current->count);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  498|      0|    for (int n = 0; n < current->count; n++)
  ------------------
  |  Branch (498:21): [True: 0, False: 0]
  ------------------
  499|      0|        priv->outbitmaps[n] = current->inbitmaps[n];
  500|       |
  501|      0|    struct sub_bitmaps *res = &(struct sub_bitmaps){0};
  502|      0|    res->parts = priv->outbitmaps;
  503|      0|    res->num_parts = current->count;
  504|      0|    if (priv->displayed_id != current->id)
  ------------------
  |  Branch (504:9): [True: 0, False: 0]
  ------------------
  505|      0|        res->change_id++;
  506|      0|    priv->displayed_id = current->id;
  507|      0|    res->packed = current->data;
  508|      0|    res->packed_w = current->bound_w;
  509|      0|    res->packed_h = current->bound_h;
  510|      0|    res->format = SUBBITMAP_BGRA;
  511|      0|    res->video_color_space = true;
  512|       |
  513|      0|    double video_par = 0;
  514|      0|    if (priv->avctx->codec_id == AV_CODEC_ID_DVD_SUBTITLE &&
  ------------------
  |  Branch (514:9): [True: 0, False: 0]
  ------------------
  515|      0|        opts->stretch_dvd_subs)
  ------------------
  |  Branch (515:9): [True: 0, False: 0]
  ------------------
  516|      0|    {
  517|       |        // For DVD subs, try to keep the subtitle PAR at display PAR.
  518|      0|        double par = priv->video_params.p_w / (double)priv->video_params.p_h;
  519|      0|        if (isnormal(par))
  ------------------
  |  Branch (519:13): [True: 0, False: 0]
  ------------------
  520|      0|            video_par = par;
  521|      0|    }
  522|      0|    if (priv->avctx->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE)
  ------------------
  |  Branch (522:9): [True: 0, False: 0]
  ------------------
  523|      0|    {
  524|       |        // For Blu-ray subs on SD video, try to match the video PAR.
  525|      0|        if (priv->video_params.w == 720 &&
  ------------------
  |  Branch (525:13): [True: 0, False: 0]
  ------------------
  526|      0|            (priv->video_params.h == 480 ||
  ------------------
  |  Branch (526:14): [True: 0, False: 0]
  ------------------
  527|      0|             priv->video_params.h == 576))
  ------------------
  |  Branch (527:14): [True: 0, False: 0]
  ------------------
  528|      0|        {
  529|      0|            double par = priv->video_params.p_w / (double)priv->video_params.p_h;
  530|      0|            if (isnormal(par))
  ------------------
  |  Branch (530:17): [True: 0, False: 0]
  ------------------
  531|      0|                video_par = par * -1;
  532|      0|            else
  533|      0|                video_par = -1;
  534|      0|        }
  535|      0|        else
  536|      0|        {
  537|       |            // Force letter-boxing on all other Blu-ray subtitles
  538|      0|            video_par = -1;
  539|      0|        }
  540|      0|    }
  541|      0|    if (opts->stretch_image_subs)
  ------------------
  |  Branch (541:9): [True: 0, False: 0]
  ------------------
  542|      0|        d.ml = d.mr = d.mt = d.mb = 0;
  543|      0|    int w = priv->avctx->width;
  544|      0|    int h = priv->avctx->height;
  545|      0|    if (w <= 0 || h <= 0 || opts->image_subs_video_res) {
  ------------------
  |  Branch (545:9): [True: 0, False: 0]
  |  Branch (545:19): [True: 0, False: 0]
  |  Branch (545:29): [True: 0, False: 0]
  ------------------
  546|      0|        w = priv->video_params.w;
  547|      0|        h = priv->video_params.h;
  548|      0|    }
  549|      0|    if (current->src_w > w || current->src_h > h) {
  ------------------
  |  Branch (549:9): [True: 0, False: 0]
  |  Branch (549:31): [True: 0, False: 0]
  ------------------
  550|      0|        w = MPMAX(priv->video_params.w, current->src_w);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  551|      0|        h = MPMAX(priv->video_params.h, current->src_h);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  552|      0|    }
  553|       |
  554|      0|    if (shared_opts->sub_pos[sd->order] != 100.0f && shared_opts->ass_style_override[sd->order]) {
  ------------------
  |  Branch (554:9): [True: 0, False: 0]
  |  Branch (554:54): [True: 0, False: 0]
  ------------------
  555|      0|        float offset = (100.0f - shared_opts->sub_pos[sd->order]) / 100.0f * h;
  556|       |
  557|      0|        for (int n = 0; n < res->num_parts; n++) {
  ------------------
  |  Branch (557:25): [True: 0, False: 0]
  ------------------
  558|      0|            struct sub_bitmap *sub = &res->parts[n];
  559|       |
  560|       |            // Decide by heuristic whether this is a sub-title or something
  561|       |            // else (top-title, covering whole screen).
  562|      0|            if (sub->y < h / 2)
  ------------------
  |  Branch (562:17): [True: 0, False: 0]
  ------------------
  563|      0|                continue;
  564|       |
  565|       |            // Allow moving up the subtitle, but only until it clips.
  566|      0|            sub->y = MPMAX(sub->y - offset, 0);
  ------------------
  |  |   44|      0|#define MPMAX(a, b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (44:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  567|      0|            sub->y = MPMIN(sub->y + sub->h, h) - sub->h;
  ------------------
  |  |   45|      0|#define MPMIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (45:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  568|      0|        }
  569|      0|    }
  570|       |
  571|      0|    osd_rescale_bitmaps(res, w, h, d, video_par);
  572|       |
  573|      0|    if (shared_opts->sub_scale[sd->order] != 1.0 && shared_opts->ass_style_override[sd->order]) {
  ------------------
  |  Branch (573:9): [True: 0, False: 0]
  |  Branch (573:53): [True: 0, False: 0]
  ------------------
  574|      0|        for (int n = 0; n < res->num_parts; n++) {
  ------------------
  |  Branch (574:25): [True: 0, False: 0]
  ------------------
  575|      0|            struct sub_bitmap *sub = &res->parts[n];
  576|       |
  577|      0|            float shit = (shared_opts->sub_scale[sd->order] - 1.0f) / 2;
  578|       |
  579|       |            // Fortunately VO isn't supposed to give a FUCKING FUCK about
  580|       |            // whether the sub might e.g. go outside of the screen.
  581|      0|            sub->x -= sub->dw * shit;
  582|      0|            sub->y -= sub->dh * shit;
  583|      0|            sub->dw += sub->dw * shit * 2;
  584|      0|            sub->dh += sub->dh * shit * 2;
  585|      0|        }
  586|      0|    }
  587|       |
  588|      0|    if (priv->prevret_num != res->num_parts)
  ------------------
  |  Branch (588:9): [True: 0, False: 0]
  ------------------
  589|      0|        res->change_id++;
  590|       |
  591|      0|    if (!res->change_id) {
  ------------------
  |  Branch (591:9): [True: 0, False: 0]
  ------------------
  592|      0|        mp_assert(priv->prevret_num == res->num_parts);
  ------------------
  |  |   41|      0|#define mp_assert assert
  ------------------
  |  Branch (592:9): [True: 0, False: 0]
  ------------------
  593|      0|        for (int n = 0; n < priv->prevret_num; n++) {
  ------------------
  |  Branch (593:25): [True: 0, False: 0]
  ------------------
  594|      0|            struct sub_bitmap *a = &res->parts[n];
  595|      0|            struct sub_bitmap *b = &priv->prevret[n];
  596|       |
  597|      0|            if (a->x != b->x || a->y != b->y ||
  ------------------
  |  Branch (597:17): [True: 0, False: 0]
  |  Branch (597:33): [True: 0, False: 0]
  ------------------
  598|      0|                a->dw != b->dw || a->dh != b->dh)
  ------------------
  |  Branch (598:17): [True: 0, False: 0]
  |  Branch (598:35): [True: 0, False: 0]
  ------------------
  599|      0|            {
  600|      0|                res->change_id++;
  601|      0|                break;
  602|      0|            }
  603|      0|        }
  604|      0|    }
  605|       |
  606|      0|    priv->prevret_num = res->num_parts;
  607|      0|    MP_TARRAY_GROW(priv, priv->prevret, priv->prevret_num);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  608|      0|    memcpy(priv->prevret, res->parts, res->num_parts * sizeof(priv->prevret[0]));
  609|       |
  610|       |    return sub_bitmaps_copy(NULL, res);
  611|      0|}
sd_lavc.c:get_current:
  463|  5.17k|{
  464|  5.17k|    struct sub *current = NULL;
  465|  25.8k|    for (int n = 0; n < MAX_QUEUE; n++) {
  ------------------
  |  |   38|  25.8k|#define MAX_QUEUE 4
  ------------------
  |  Branch (465:21): [True: 20.7k, False: 5.17k]
  ------------------
  466|  20.7k|        struct sub *sub = &priv->subs[n];
  467|  20.7k|        if (!sub->valid)
  ------------------
  |  Branch (467:13): [True: 20.7k, False: 0]
  ------------------
  468|  20.7k|            continue;
  469|      0|        if (pts == MP_NOPTS_VALUE ||
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (469:13): [True: 0, False: 0]
  ------------------
  470|      0|            ((sub->pts == MP_NOPTS_VALUE || pts + 1e-6 >= sub->pts) &&
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (470:15): [True: 0, False: 0]
  |  Branch (470:45): [True: 0, False: 0]
  ------------------
  471|      0|             (sub->endpts == MP_NOPTS_VALUE || pts + 1e-6 < sub->endpts)))
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (471:15): [True: 0, False: 0]
  |  Branch (471:48): [True: 0, False: 0]
  ------------------
  472|      0|        {
  473|       |            // Ignore "trailing" subtitles with unknown length after 1 minute.
  474|      0|            if (sub->endpts == MP_NOPTS_VALUE && pts >= sub->pts + 60)
  ------------------
  |  |   39|      0|#define MP_NOPTS_VALUE (-0x1p+63)
  ------------------
  |  Branch (474:17): [True: 0, False: 0]
  |  Branch (474:50): [True: 0, False: 0]
  ------------------
  475|      0|                break;
  476|      0|            current = sub;
  477|      0|            break;
  478|      0|        }
  479|      0|    }
  480|  5.17k|    return current;
  481|  5.17k|}

ta_set_parent:
   88|   576M|{
   89|   576M|    struct ta_header *ch = get_header(ptr);
   90|   576M|    if (!ch)
  ------------------
  |  Branch (90:9): [True: 390k, False: 576M]
  ------------------
   91|   390k|        return;
   92|   576M|    struct ta_header *new_parent = get_header(ta_parent);
   93|       |    // Unlink from previous parent
   94|   576M|    if (ch->prev)
  ------------------
  |  Branch (94:9): [True: 348k, False: 575M]
  ------------------
   95|   348k|        ch->prev->next = ch->next;
   96|   576M|    if (ch->next)
  ------------------
  |  Branch (96:9): [True: 77.6M, False: 498M]
  ------------------
   97|  77.6M|        ch->next->prev = ch->prev;
   98|       |    // If ch was the first child, change child link of old parent
   99|   576M|    if (ch->parent) {
  ------------------
  |  Branch (99:9): [True: 116M, False: 460M]
  ------------------
  100|   116M|        assert(ch->parent->child == ch);
  ------------------
  |  Branch (100:9): [True: 116M, False: 18.4E]
  ------------------
  101|   116M|        ch->parent->child = ch->next;
  102|   116M|        if (ch->parent->child) {
  ------------------
  |  Branch (102:13): [True: 77.3M, False: 38.6M]
  ------------------
  103|  77.3M|            assert(!ch->parent->child->parent);
  ------------------
  |  Branch (103:13): [True: 77.3M, False: 18.4E]
  ------------------
  104|  77.3M|            ch->parent->child->parent = ch->parent;
  105|  77.3M|        }
  106|   116M|    }
  107|   576M|    ch->next = ch->prev = ch->parent = NULL;
  108|       |    // Link to new parent - insert at start of list (LIFO destructor order)
  109|   576M|    if (new_parent) {
  ------------------
  |  Branch (109:9): [True: 116M, False: 459M]
  ------------------
  110|   116M|        ch->next = new_parent->child;
  111|   116M|        if (ch->next) {
  ------------------
  |  Branch (111:13): [True: 77.7M, False: 38.6M]
  ------------------
  112|  77.7M|            ch->next->prev = ch;
  113|       |            ch->next->parent = NULL;
  114|  77.7M|        }
  115|   116M|        new_parent->child = ch;
  116|   116M|        ch->parent = new_parent;
  117|   116M|    }
  118|   576M|}
ta_alloc_size:
  136|   179M|{
  137|   179M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|   179M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (137:9): [True: 0, False: 179M]
  ------------------
  138|      0|        return NULL;
  139|   179M|    struct ta_header *h = malloc(sizeof(union aligned_header) + size);
  140|   179M|    if (!h)
  ------------------
  |  Branch (140:9): [True: 0, False: 179M]
  ------------------
  141|      0|        return NULL;
  142|   179M|    *h = (struct ta_header) {.size = size};
  143|   179M|    ta_dbg_add(h);
  144|   179M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|   179M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  145|   179M|    ta_set_parent(ptr, ta_parent);
  146|   179M|    return ptr;
  147|   179M|}
ta_zalloc_size:
  153|  42.9M|{
  154|  42.9M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|  42.9M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (154:9): [True: 0, False: 42.9M]
  ------------------
  155|      0|        return NULL;
  156|  42.9M|    struct ta_header *h = calloc(1, sizeof(union aligned_header) + size);
  157|  42.9M|    if (!h)
  ------------------
  |  Branch (157:9): [True: 0, False: 42.9M]
  ------------------
  158|      0|        return NULL;
  159|  42.9M|    *h = (struct ta_header) {.size = size};
  160|  42.9M|    ta_dbg_add(h);
  161|  42.9M|    void *ptr = PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  42.9M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  162|  42.9M|    ta_set_parent(ptr, ta_parent);
  163|  42.9M|    return ptr;
  164|  42.9M|}
ta_realloc_size:
  179|   140M|{
  180|   140M|    if (size >= MAX_ALLOC)
  ------------------
  |  |   66|   140M|#define MAX_ALLOC (((size_t)-1) - sizeof(union aligned_header))
  ------------------
  |  Branch (180:9): [True: 0, False: 140M]
  ------------------
  181|      0|        return NULL;
  182|   140M|    if (!size) {
  ------------------
  |  Branch (182:9): [True: 113k, False: 140M]
  ------------------
  183|   113k|        ta_free(ptr);
  184|   113k|        return NULL;
  185|   113k|    }
  186|   140M|    if (!ptr)
  ------------------
  |  Branch (186:9): [True: 135M, False: 4.94M]
  ------------------
  187|   135M|        return ta_alloc_size(ta_parent, size);
  188|  4.94M|    struct ta_header *h = get_header(ptr);
  189|  4.94M|    struct ta_header *old_h = h;
  190|  4.94M|    if (h->size == size)
  ------------------
  |  Branch (190:9): [True: 2.70k, False: 4.94M]
  ------------------
  191|  2.70k|        return ptr;
  192|  4.94M|    ta_dbg_remove(h);
  193|  4.94M|    h = realloc(h, sizeof(union aligned_header) + size);
  194|  18.4E|    ta_dbg_add(h ? h : old_h);
  ------------------
  |  Branch (194:16): [True: 4.94M, False: 18.4E]
  ------------------
  195|  4.94M|    if (!h)
  ------------------
  |  Branch (195:9): [True: 0, False: 4.94M]
  ------------------
  196|      0|        return NULL;
  197|  4.94M|    h->size = size;
  198|  4.94M|    if (h != old_h) {
  ------------------
  |  Branch (198:9): [True: 4.03M, False: 914k]
  ------------------
  199|       |        // Relink parent
  200|  4.03M|        if (h->parent)
  ------------------
  |  Branch (200:13): [True: 802k, False: 3.22M]
  ------------------
  201|   802k|            h->parent->child = h;
  202|       |        // Relink siblings
  203|  4.03M|        if (h->next)
  ------------------
  |  Branch (203:13): [True: 2.33M, False: 1.69M]
  ------------------
  204|  2.33M|            h->next->prev = h;
  205|  4.03M|        if (h->prev)
  ------------------
  |  Branch (205:13): [True: 2.84M, False: 1.18M]
  ------------------
  206|  2.84M|            h->prev->next = h;
  207|       |        // Relink children
  208|  4.03M|        if (h->child)
  ------------------
  |  Branch (208:13): [True: 0, False: 4.03M]
  ------------------
  209|      0|            h->child->parent = h;
  210|  4.03M|    }
  211|  4.94M|    return PTR_FROM_HEADER(h);
  ------------------
  |  |   64|  4.94M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  212|  4.94M|}
ta_get_size:
  219|   494M|{
  220|   494M|    struct ta_header *h = get_header(ptr);
  221|   494M|    return h ? h->size : 0;
  ------------------
  |  Branch (221:12): [True: 231M, False: 263M]
  ------------------
  222|   494M|}
ta_free_children:
  228|   228M|{
  229|   228M|    struct ta_header *h = get_header(ptr);
  230|   343M|    while (h && h->child)
  ------------------
  |  Branch (230:12): [True: 343M, False: 417]
  |  Branch (230:17): [True: 115M, False: 228M]
  ------------------
  231|   115M|        ta_free(PTR_FROM_HEADER(h->child));
  ------------------
  |  |   64|   115M|#define PTR_FROM_HEADER(h) ((void *)((union aligned_header *)(h) + 1))
  ------------------
  232|   228M|}
ta_free:
  237|   258M|{
  238|   258M|    struct ta_header *h = get_header(ptr);
  239|   258M|    if (!h)
  ------------------
  |  Branch (239:9): [True: 36.3M, False: 222M]
  ------------------
  240|  36.3M|        return;
  241|   222M|    if (h->destructor)
  ------------------
  |  Branch (241:9): [True: 36.0M, False: 186M]
  ------------------
  242|  36.0M|        h->destructor(ptr);
  243|   222M|    ta_free_children(ptr);
  244|       |    ta_set_parent(ptr, NULL);
  245|   222M|    ta_dbg_remove(h);
  246|   222M|    free(h);
  247|   222M|}
ta_set_destructor:
  260|  36.0M|{
  261|  36.0M|    struct ta_header *h = get_header(ptr);
  262|  36.0M|    if (h)
  ------------------
  |  Branch (262:9): [True: 36.0M, False: 1]
  ------------------
  263|  36.0M|        h->destructor = destructor;
  264|  36.0M|}
ta_dbg_set_loc:
  379|   230M|{
  380|   230M|    struct ta_header *h = get_header(ptr);
  381|   230M|    if (h)
  ------------------
  |  Branch (381:9): [True: 227M, False: 2.92M]
  ------------------
  382|   227M|        h->name = loc;
  383|   230M|    return ptr;
  384|   230M|}
ta_dbg_mark_as_string:
  389|   129M|{
  390|       |    // Specially handled by leak report code.
  391|   129M|    return ta_dbg_set_loc(ptr, &allocation_is_string);
  392|   129M|}
ta.c:get_header:
   73|  2.40G|{
   74|  2.40G|    struct ta_header *h = ptr ? PTR_TO_HEADER(ptr) : NULL;
  ------------------
  |  |   63|  1.64G|#define PTR_TO_HEADER(ptr) (&((union aligned_header *)(ptr) - 1)->ta)
  ------------------
  |  Branch (74:27): [True: 1.64G, False: 762M]
  ------------------
   75|  2.40G|    ta_dbg_check_header(h);
   76|  2.40G|    return h;
   77|  2.40G|}
ta.c:ta_dbg_check_header:
  289|  2.63G|{
  290|  2.63G|    if (h) {
  ------------------
  |  Branch (290:9): [True: 1.87G, False: 762M]
  ------------------
  291|  1.87G|        assert(h->canary == CANARY);
  ------------------
  |  Branch (291:9): [True: 1.87G, False: 18.4E]
  ------------------
  292|  1.87G|        if (h->parent) {
  ------------------
  |  Branch (292:13): [True: 559M, False: 1.31G]
  ------------------
  293|   559M|            assert(!h->prev);
  ------------------
  |  Branch (293:13): [True: 559M, False: 18.4E]
  ------------------
  294|   559M|            assert(h->parent->child == h);
  ------------------
  |  Branch (294:13): [True: 559M, False: 18.4E]
  ------------------
  295|   559M|        }
  296|  1.87G|    }
  297|  2.63G|}
ta.c:ta_dbg_add:
  276|   227M|{
  277|   227M|    h->canary = CANARY;
  ------------------
  |  |   50|   227M|#define CANARY 0xD3ADB3EF
  ------------------
  278|   227M|    if (enable_leak_check) {
  ------------------
  |  Branch (278:9): [True: 0, False: 227M]
  ------------------
  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|   227M|}
ta.c:ta_dbg_remove:
  300|   227M|{
  301|   227M|    ta_dbg_check_header(h);
  302|   227M|    if (h->leak_next) { // assume checking for !=NULL invariant ok without lock
  ------------------
  |  Branch (302:9): [True: 0, False: 227M]
  ------------------
  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|   227M|    h->canary = 0;
  310|   227M|}

client.c:ta_oom_p:
  162|   292k|{
  163|   292k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 292k]
  ------------------
  164|      0|        abort();
  165|   292k|    return p;
  166|   292k|}
command.c:ta_oom_p:
  162|   195k|{
  163|   195k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 195k]
  ------------------
  164|      0|        abort();
  165|   195k|    return p;
  166|   195k|}
configfiles.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
loadfile.c:ta_oom_p:
  162|   241k|{
  163|   241k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 241k]
  ------------------
  164|      0|        abort();
  165|   241k|    return p;
  166|   241k|}
main.c:ta_oom_p:
  162|  97.5k|{
  163|  97.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 97.5k]
  ------------------
  164|      0|        abort();
  165|  97.5k|    return p;
  166|  97.5k|}
osd.c:ta_oom_b:
  169|   812k|{
  170|   812k|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 812k]
  ------------------
  171|      0|        abort();
  172|   812k|}
osd.c:ta_oom_p:
  162|  1.04M|{
  163|  1.04M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 1.04M]
  ------------------
  164|      0|        abort();
  165|  1.04M|    return p;
  166|  1.04M|}
screenshot.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
scripting.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
sub.c:ta_oom_p:
  162|  6.68k|{
  163|  6.68k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 6.68k]
  ------------------
  164|      0|        abort();
  165|  6.68k|    return p;
  166|  6.68k|}
video.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
clipboard.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
clipboard-vo.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
stream.c:ta_oom_p:
  162|   122k|{
  163|   122k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 122k]
  ------------------
  164|      0|        abort();
  165|   122k|    return p;
  166|   122k|}
stream_file.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
stream_lavf.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
stream_bstr.c:ta_oom_p:
  162|  57.6k|{
  163|  57.6k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 57.6k]
  ------------------
  164|      0|        abort();
  165|  57.6k|    return p;
  166|  57.6k|}
dec_sub.c:ta_oom_p:
  162|  19.8k|{
  163|  19.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 19.8k]
  ------------------
  164|      0|        abort();
  165|  19.8k|    return p;
  166|  19.8k|}
packer.c:ta_oom_p:
  162|  12.9k|{
  163|  12.9k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.9k]
  ------------------
  164|      0|        abort();
  165|  12.9k|    return p;
  166|  12.9k|}
sd_ass.c:ta_oom_p:
  162|  19.3k|{
  163|  19.3k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 19.3k]
  ------------------
  164|      0|        abort();
  165|  19.3k|    return p;
  166|  19.3k|}
sd_lavc.c:ta_oom_p:
  162|    414|{
  163|    414|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 414]
  ------------------
  164|      0|        abort();
  165|    414|    return p;
  166|    414|}
mp_image.c:ta_oom_p:
  162|  2.43M|{
  163|  2.43M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.43M]
  ------------------
  164|      0|        abort();
  165|  2.43M|    return p;
  166|  2.43M|}
mp_image_pool.c:ta_oom_p:
  162|  97.5k|{
  163|  97.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 97.5k]
  ------------------
  164|      0|        abort();
  165|  97.5k|    return p;
  166|  97.5k|}
vo.c:ta_oom_p:
  162|  1.75M|{
  163|  1.75M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 1.75M]
  ------------------
  164|      0|        abort();
  165|  1.75M|    return p;
  166|  1.75M|}
ta_talloc.c:ta_oom_b:
  169|  25.9k|{
  170|  25.9k|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 25.9k]
  ------------------
  171|      0|        abort();
  172|  25.9k|}
ta_utils.c:ta_oom_b:
  169|   162M|{
  170|   162M|    if (!b)
  ------------------
  |  Branch (170:9): [True: 0, False: 162M]
  ------------------
  171|      0|        abort();
  172|   162M|}
ipc-unix.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
filter_regex.c:ta_oom_p:
  162|  6.45k|{
  163|  6.45k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 6.45k]
  ------------------
  164|      0|        abort();
  165|  6.45k|    return p;
  166|  6.45k|}
aframe.c:ta_oom_p:
  162|   292k|{
  163|   292k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 292k]
  ------------------
  164|      0|        abort();
  165|   292k|    return p;
  166|   292k|}
codecs.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
msg.c:ta_oom_p:
  162|  3.42M|{
  163|  3.42M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 3.42M]
  ------------------
  164|      0|        abort();
  165|  3.42M|    return p;
  166|  3.42M|}
msg.c:ta_oom_s:
  175|   351k|{
  176|   351k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 351k]
  ------------------
  177|      0|        abort();
  178|   351k|    return s;
  179|   351k|}
playlist.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
stats.c:ta_oom_p:
  162|   629k|{
  163|   629k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 629k]
  ------------------
  164|      0|        abort();
  165|   629k|    return p;
  166|   629k|}
stats.c:ta_oom_s:
  175|  87.6k|{
  176|  87.6k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 87.6k]
  ------------------
  177|      0|        abort();
  178|  87.6k|    return s;
  179|  87.6k|}
tags.c:ta_oom_p:
  162|  90.0k|{
  163|  90.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 90.0k]
  ------------------
  164|      0|        abort();
  165|  90.0k|    return p;
  166|  90.0k|}
demux.c:ta_oom_p:
  162|  2.14M|{
  163|  2.14M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 2.14M]
  ------------------
  164|      0|        abort();
  165|  2.14M|    return p;
  166|  2.14M|}
demux_cue.c:ta_oom_p:
  162|     62|{
  163|     62|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 62]
  ------------------
  164|      0|        abort();
  165|     62|    return p;
  166|     62|}
demux_disc.c:ta_oom_p:
  162|  40.0k|{
  163|  40.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 40.0k]
  ------------------
  164|      0|        abort();
  165|  40.0k|    return p;
  166|  40.0k|}
demux_edl.c:ta_oom_p:
  162|  40.0k|{
  163|  40.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 40.0k]
  ------------------
  164|      0|        abort();
  165|  40.0k|    return p;
  166|  40.0k|}
demux_lavf.c:ta_oom_p:
  162|   291k|{
  163|   291k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 291k]
  ------------------
  164|      0|        abort();
  165|   291k|    return p;
  166|   291k|}
demux_mf.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|}
demux_mkv.c:ta_oom_p:
  162|  42.2k|{
  163|  42.2k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 42.2k]
  ------------------
  164|      0|        abort();
  165|  42.2k|    return p;
  166|  42.2k|}
demux_playlist.c:ta_oom_p:
  162|   110k|{
  163|   110k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 110k]
  ------------------
  164|      0|        abort();
  165|   110k|    return p;
  166|   110k|}
ebml.c:ta_oom_p:
  162|  4.10k|{
  163|  4.10k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.10k]
  ------------------
  164|      0|        abort();
  165|  4.10k|    return p;
  166|  4.10k|}
packet.c:ta_oom_p:
  162|   879k|{
  163|   879k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 879k]
  ------------------
  164|      0|        abort();
  165|   879k|    return p;
  166|   879k|}
packet_pool.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
timeline.c:ta_oom_p:
  162|    551|{
  163|    551|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 551]
  ------------------
  164|      0|        abort();
  165|    551|    return p;
  166|    551|}
f_decoder_wrapper.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
f_output_chain.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
filter.c:ta_oom_p:
  162|  4.12M|{
  163|  4.12M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.12M]
  ------------------
  164|      0|        abort();
  165|  4.12M|    return p;
  166|  4.12M|}
cmd.c:ta_oom_p:
  162|   195k|{
  163|   195k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 195k]
  ------------------
  164|      0|        abort();
  165|   195k|    return p;
  166|   195k|}
input.c:ta_oom_p:
  162|   162k|{
  163|   162k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 162k]
  ------------------
  164|      0|        abort();
  165|   162k|    return p;
  166|   162k|}
charset_conv.c:ta_oom_p:
  162|  25.0k|{
  163|  25.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 25.0k]
  ------------------
  164|      0|        abort();
  165|  25.0k|    return p;
  166|  25.0k|}
dispatch.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|}
node.c:ta_oom_p:
  162|  97.5k|{
  163|  97.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 97.5k]
  ------------------
  164|      0|        abort();
  165|  97.5k|    return p;
  166|  97.5k|}
thread_pool.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
thread_tools.c:ta_oom_p:
  162|   162k|{
  163|   162k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 162k]
  ------------------
  164|      0|        abort();
  165|   162k|    return p;
  166|   162k|}
m_config_core.c:ta_oom_p:
  162|  12.6M|{
  163|  12.6M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 12.6M]
  ------------------
  164|      0|        abort();
  165|  12.6M|    return p;
  166|  12.6M|}
m_config_frontend.c:ta_oom_p:
  162|  48.3M|{
  163|  48.3M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 48.3M]
  ------------------
  164|      0|        abort();
  165|  48.3M|    return p;
  166|  48.3M|}
m_option.c:ta_oom_s:
  175|  97.5k|{
  176|  97.5k|    if (!s)
  ------------------
  |  Branch (176:9): [True: 0, False: 97.5k]
  ------------------
  177|      0|        abort();
  178|  97.5k|    return s;
  179|  97.5k|}
m_option.c:ta_oom_p:
  162|  4.95M|{
  163|  4.95M|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 4.95M]
  ------------------
  164|      0|        abort();
  165|  4.95M|    return p;
  166|  4.95M|}
parse_configfile.c:ta_oom_p:
  162|  32.5k|{
  163|  32.5k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 32.5k]
  ------------------
  164|      0|        abort();
  165|  32.5k|    return p;
  166|  32.5k|}
path.c:ta_oom_p:
  162|   312k|{
  163|   312k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 312k]
  ------------------
  164|      0|        abort();
  165|   312k|    return p;
  166|   312k|}
external_files.c:ta_oom_p:
  162|  65.0k|{
  163|  65.0k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 65.0k]
  ------------------
  164|      0|        abort();
  165|  65.0k|    return p;
  166|  65.0k|}
ass_mp.c:ta_oom_p:
  162|  6.45k|{
  163|  6.45k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 6.45k]
  ------------------
  164|      0|        abort();
  165|  6.45k|    return p;
  166|  6.45k|}
filter_sdh.c:ta_oom_p:
  162|  57.7k|{
  163|  57.7k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 57.7k]
  ------------------
  164|      0|        abort();
  165|  57.7k|    return p;
  166|  57.7k|}
lavc_conv.c:ta_oom_p:
  162|  11.8k|{
  163|  11.8k|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 11.8k]
  ------------------
  164|      0|        abort();
  165|  11.8k|    return p;
  166|  11.8k|}
cue.c:ta_oom_p:
  162|    112|{
  163|    112|    if (!p)
  ------------------
  |  Branch (163:9): [True: 0, False: 112]
  ------------------
  164|      0|        abort();
  165|    112|    return p;
  166|    112|}

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

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

mp_stereo3d_from_av:
  157|    356|{
  158|    356|    bool inv = s3d->flags & AV_STEREO3D_FLAG_INVERT;
  159|    356|    switch (s3d->type) {
  160|      0|    case AV_STEREO3D_SIDEBYSIDE:
  ------------------
  |  Branch (160:5): [True: 0, False: 356]
  ------------------
  161|      0|    case AV_STEREO3D_SIDEBYSIDE_QUINCUNX:
  ------------------
  |  Branch (161:5): [True: 0, False: 356]
  ------------------
  162|      0|        return inv ? MP_STEREO3D_SBS2R : MP_STEREO3D_SBS2L;
  ------------------
  |  Branch (162:16): [True: 0, False: 0]
  ------------------
  163|      0|    case AV_STEREO3D_TOPBOTTOM:
  ------------------
  |  Branch (163:5): [True: 0, False: 356]
  ------------------
  164|      0|        return inv ? MP_STEREO3D_AB2R : MP_STEREO3D_AB2L;
  ------------------
  |  Branch (164:16): [True: 0, False: 0]
  ------------------
  165|      0|    case AV_STEREO3D_CHECKERBOARD:
  ------------------
  |  Branch (165:5): [True: 0, False: 356]
  ------------------
  166|      0|        return inv ? MP_STEREO3D_CHECKR : MP_STEREO3D_CHECKL;
  ------------------
  |  Branch (166:16): [True: 0, False: 0]
  ------------------
  167|      0|    case AV_STEREO3D_LINES:
  ------------------
  |  Branch (167:5): [True: 0, False: 356]
  ------------------
  168|      0|        return inv ? MP_STEREO3D_IRR : MP_STEREO3D_IRL;
  ------------------
  |  Branch (168:16): [True: 0, False: 0]
  ------------------
  169|      0|    case AV_STEREO3D_COLUMNS:
  ------------------
  |  Branch (169:5): [True: 0, False: 356]
  ------------------
  170|      0|        return inv ? MP_STEREO3D_ICR : MP_STEREO3D_ICL;
  ------------------
  |  Branch (170:16): [True: 0, False: 0]
  ------------------
  171|      0|    case AV_STEREO3D_FRAMESEQUENCE:
  ------------------
  |  Branch (171:5): [True: 0, False: 356]
  ------------------
  172|      0|        return inv ? MP_STEREO3D_AR : MP_STEREO3D_AL;
  ------------------
  |  Branch (172:16): [True: 0, False: 0]
  ------------------
  173|    356|    default:
  ------------------
  |  Branch (173:5): [True: 356, False: 0]
  ------------------
  174|       |        // AV_STEREO3D_2D and types mpv has no mode for.
  175|    356|        return MP_STEREO3D_MONO;
  176|    356|    }
  177|    356|}
mp_csp_guess_colorspace:
  191|  32.5k|{
  192|  32.5k|    return width >= 1280 || height > 576 ? PL_COLOR_SYSTEM_BT_709 : PL_COLOR_SYSTEM_BT_601;
  ------------------
  |  Branch (192:12): [True: 0, False: 32.5k]
  |  Branch (192:29): [True: 0, False: 32.5k]
  ------------------
  193|  32.5k|}
mp_csp_guess_primaries:
  196|  32.5k|{
  197|       |    // HD content
  198|  32.5k|    if (width >= 1280 || height > 576)
  ------------------
  |  Branch (198:9): [True: 0, False: 32.5k]
  |  Branch (198:26): [True: 0, False: 32.5k]
  ------------------
  199|      0|        return PL_COLOR_PRIM_BT_709;
  200|       |
  201|  32.5k|    switch (height) {
  202|      0|    case 576: // Typical PAL content, including anamorphic/squared
  ------------------
  |  Branch (202:5): [True: 0, False: 32.5k]
  ------------------
  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: 32.5k]
  ------------------
  206|      0|    case 486: // NTSC Pro or anamorphic NTSC
  ------------------
  |  Branch (206:5): [True: 0, False: 32.5k]
  ------------------
  207|      0|        return PL_COLOR_PRIM_BT_601_525;
  208|       |
  209|  32.5k|    default: // No good metric, just pick BT.709 to minimize damage
  ------------------
  |  Branch (209:5): [True: 32.5k, False: 0]
  ------------------
  210|  32.5k|        return PL_COLOR_PRIM_BT_709;
  211|  32.5k|    }
  212|  32.5k|}

vd_lavc.c:add_all_hwdec_methods:
  346|  32.5k|{
  347|  32.5k|    const AVCodec *codec = NULL;
  348|  32.5k|    void *iter = NULL;
  349|  16.3M|    while (1) {
  ------------------
  |  Branch (349:12): [True: 16.3M, Folded]
  ------------------
  350|  16.3M|        codec = av_codec_iterate(&iter);
  351|  16.3M|        if (!codec)
  ------------------
  |  Branch (351:13): [True: 32.5k, False: 16.2M]
  ------------------
  352|  32.5k|            break;
  353|  16.2M|        if (codec->type != AVMEDIA_TYPE_VIDEO || !av_codec_is_decoder(codec))
  ------------------
  |  Branch (353:13): [True: 7.96M, False: 8.32M]
  |  Branch (353:50): [True: 0, False: 8.32M]
  ------------------
  354|  7.96M|            continue;
  355|       |
  356|  8.32M|        struct hwdec_info info_template = {
  357|  8.32M|            .pix_fmt = AV_PIX_FMT_NONE,
  358|  8.32M|            .codec = codec,
  359|  8.32M|        };
  360|       |
  361|  8.32M|        const char *wrapper = NULL;
  362|  8.32M|        if (codec->capabilities & (AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_HYBRID))
  ------------------
  |  Branch (362:13): [True: 292k, False: 8.03M]
  ------------------
  363|   292k|            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|  8.32M|        bool found_any = false;
  369|  8.32M|        for (int n = 0; ; n++) {
  370|  8.32M|            const AVCodecHWConfig *cfg = avcodec_get_hw_config(codec, n);
  371|  8.32M|            if (!cfg)
  ------------------
  |  Branch (371:17): [True: 8.32M, False: 0]
  ------------------
  372|  8.32M|                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|  8.32M|        if (!found_any && wrapper) {
  ------------------
  |  Branch (435:13): [True: 8.32M, False: 0]
  |  Branch (435:27): [True: 292k, False: 8.03M]
  ------------------
  436|       |            // We _know_ there's something supported here, usually outputting
  437|       |            // sw surfaces. E.g. mediacodec (before hw_device_ctx support).
  438|       |
  439|   292k|            struct hwdec_info info = info_template;
  440|   292k|            info.copying = true; // probably
  441|       |
  442|   292k|            snprintf(info.method_name, sizeof(info.method_name), "%s", wrapper);
  443|   292k|            add_hwdec_item(infos, num_infos, info);
  444|   292k|        }
  445|  8.32M|    }
  446|       |
  447|  32.5k|    qsort(*infos, *num_infos, sizeof(struct hwdec_info), hwdec_compare);
  448|  32.5k|}
vd_lavc.c:add_hwdec_item:
  321|   292k|{
  322|   292k|    if (info.copying)
  ------------------
  |  Branch (322:9): [True: 292k, False: 0]
  ------------------
  323|   292k|        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|   292k|    snprintf(info.name, sizeof(info.name), "%s-%s",
  328|   292k|             info.codec->name, info.method_name);
  329|       |
  330|   292k|    info.rank = *num_infos;
  331|   292k|    info.auto_pos = INT_MAX;
  332|       |
  333|  5.56M|    for (int x = 0; hwdec_autoprobe_info[x].method_name; x++) {
  ------------------
  |  Branch (333:21): [True: 5.26M, False: 292k]
  ------------------
  334|  5.26M|        const struct autoprobe_info *entry = &hwdec_autoprobe_info[x];
  335|  5.26M|        if (strcmp(entry->method_name, info.method_name) == 0) {
  ------------------
  |  Branch (335:13): [True: 0, False: 5.26M]
  ------------------
  336|      0|            info.flags |= entry->flags;
  337|      0|            if (info.flags & HWDEC_FLAG_AUTO)
  ------------------
  |  Branch (337:17): [True: 0, False: 0]
  ------------------
  338|      0|                info.auto_pos = x;
  339|      0|        }
  340|  5.26M|    }
  341|       |
  342|   292k|    MP_TARRAY_APPEND(NULL, *infos, *num_infos, info);
  ------------------
  |  |  105|   292k|    do {                                            \
  |  |  106|   292k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   292k|    do {                                            \
  |  |  |  |   97|   292k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   292k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   292k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   292k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 97.5k, False: 195k]
  |  |  |  |  ------------------
  |  |  |  |   99|   292k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  97.5k|    do {                                                        \
  |  |  |  |  |  |   89|  97.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  97.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  97.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  97.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  97.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  97.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  97.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 97.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   292k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 292k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   292k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   292k|        (idxvar)++;                                 \
  |  |  109|   292k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 292k]
  |  |  ------------------
  ------------------
  343|   292k|}
vd_lavc.c:hwdec_compare:
  295|   422k|{
  296|   422k|    struct hwdec_info *h1 = (void *)p1;
  297|   422k|    struct hwdec_info *h2 = (void *)p2;
  298|       |
  299|   422k|    if (h1 == h2)
  ------------------
  |  Branch (299:9): [True: 0, False: 422k]
  ------------------
  300|      0|        return 0;
  301|       |
  302|       |    // Strictly put non-preferred hwdecs to the end of the list.
  303|   422k|    if ((h1->auto_pos == INT_MAX) != (h2->auto_pos == INT_MAX))
  ------------------
  |  Branch (303:9): [True: 0, False: 422k]
  ------------------
  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|   422k|    if (h1->copying != h2->copying)
  ------------------
  |  Branch (306:9): [True: 0, False: 422k]
  ------------------
  307|      0|        return h1->copying ? 1 : -1;
  ------------------
  |  Branch (307:16): [True: 0, False: 0]
  ------------------
  308|       |    // Order by autoprobe preference order.
  309|   422k|    if (h1->auto_pos != h2->auto_pos)
  ------------------
  |  Branch (309:9): [True: 0, False: 422k]
  ------------------
  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|   422k|    if ((!!h1->lavc_device) != (!!h2->lavc_device))
  ------------------
  |  Branch (312:9): [True: 0, False: 422k]
  ------------------
  313|      0|        return h1->lavc_device ? -1 : 1;
  ------------------
  |  Branch (313:16): [True: 0, False: 0]
  ------------------
  314|       |    // Fallback sort order to make sorting stable.
  315|   422k|    return h1->rank > h2->rank ? 1 :-1;
  ------------------
  |  Branch (315:12): [True: 0, False: 422k]
  ------------------
  316|   422k|}
vd_lavc.c:create:
 1503|  32.5k|{
 1504|  32.5k|    struct mp_filter *vd = mp_filter_create(parent, &vd_lavc_filter);
 1505|  32.5k|    if (!vd)
  ------------------
  |  Branch (1505:9): [True: 0, False: 32.5k]
  ------------------
 1506|      0|        return NULL;
 1507|       |
 1508|  32.5k|    mp_filter_add_pin(vd, MP_PIN_IN, "in");
 1509|  32.5k|    mp_filter_add_pin(vd, MP_PIN_OUT, "out");
 1510|       |
 1511|  32.5k|    vd->log = mp_log_new(vd, parent->log, NULL);
 1512|       |
 1513|  32.5k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1514|  32.5k|    ctx->log = vd->log;
 1515|  32.5k|    ctx->opts_cache = m_config_cache_alloc(ctx, vd->global, &vd_lavc_conf);
 1516|  32.5k|    ctx->opts = ctx->opts_cache->opts;
 1517|  32.5k|    ctx->hwdec_opts_cache = m_config_cache_alloc(ctx, vd->global, &hwdec_conf);
 1518|  32.5k|    ctx->hwdec_opts = ctx->hwdec_opts_cache->opts;
 1519|  32.5k|    ctx->codec = codec;
 1520|  32.5k|    ctx->decoder = talloc_strdup(ctx, decoder);
  ------------------
  |  |   50|  32.5k|#define talloc_strdup                   ta_xstrdup
  ------------------
 1521|  32.5k|    ctx->hwdec_swpool = mp_image_pool_new(ctx);
 1522|  32.5k|    ctx->dr_pool = mp_image_pool_new(ctx);
 1523|       |
 1524|  32.5k|    ctx->public.f = vd;
 1525|  32.5k|    ctx->public.control = control;
 1526|       |
 1527|  32.5k|    mp_mutex_init(&ctx->dr_lock);
 1528|       |
 1529|       |    // hwdec/DR
 1530|  32.5k|    struct mp_stream_info *info = mp_filter_find_stream_info(vd);
 1531|  32.5k|    if (info) {
  ------------------
  |  Branch (1531:9): [True: 32.5k, False: 0]
  ------------------
 1532|  32.5k|        ctx->hwdec_devs = info->hwdec_devs;
 1533|  32.5k|        ctx->vo = info->dr_vo;
 1534|  32.5k|        ctx->force_swdec = info->force_swdec;
 1535|  32.5k|    }
 1536|       |
 1537|  32.5k|    reinit(vd);
 1538|       |
 1539|  32.5k|    if (!ctx->avctx) {
  ------------------
  |  Branch (1539:9): [True: 0, False: 32.5k]
  ------------------
 1540|      0|        talloc_free(vd);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
 1541|      0|        return NULL;
 1542|      0|    }
 1543|       |
 1544|  32.5k|    codec->codec_desc = ctx->avctx->codec_descriptor->long_name;
 1545|       |
 1546|  32.5k|    return &ctx->public;
 1547|  32.5k|}
vd_lavc.c:vd_lavc_destroy:
 1484|  32.5k|{
 1485|  32.5k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1486|       |
 1487|  32.5k|    uninit_avctx(vd);
 1488|       |
 1489|  32.5k|    mp_mutex_destroy(&ctx->dr_lock);
  ------------------
  |  |  133|  32.5k|#define mp_mutex_destroy    pthread_mutex_destroy
  ------------------
 1490|  32.5k|}
vd_lavc.c:uninit_avctx:
  937|  65.0k|{
  938|  65.0k|    vd_ffmpeg_ctx *ctx = vd->priv;
  939|       |
  940|  65.0k|    flush_all(vd);
  941|  65.0k|    av_frame_free(&ctx->pic);
  942|  65.0k|    mp_free_av_packet(&ctx->avpkt);
  943|  65.0k|    av_buffer_unref(&ctx->cached_hw_frames_ctx);
  944|       |
  945|  65.0k|    avcodec_free_context(&ctx->avctx);
  946|       |
  947|  65.0k|    av_buffer_unref(&ctx->hwdec_dev);
  948|       |
  949|  65.0k|    ctx->hwdec_failed = false;
  950|  65.0k|    ctx->hwdec_fail_count = 0;
  951|  65.0k|    ctx->max_delay_queue = 0;
  952|  65.0k|    ctx->hw_probing = false;
  953|  65.0k|    ctx->hwdec = (struct hwdec_info){0};
  954|       |    ctx->use_hwdec = false;
  955|  65.0k|}
vd_lavc.c:flush_all:
  918|  65.0k|{
  919|  65.0k|    vd_ffmpeg_ctx *ctx = vd->priv;
  920|       |
  921|  65.0k|    for (int n = 0; n < ctx->num_delay_queue; n++)
  ------------------
  |  Branch (921:21): [True: 0, False: 65.0k]
  ------------------
  922|      0|        talloc_free(ctx->delay_queue[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  923|  65.0k|    ctx->num_delay_queue = 0;
  924|       |
  925|  65.0k|    for (int n = 0; n < ctx->num_sent_packets; n++)
  ------------------
  |  Branch (925:21): [True: 0, False: 65.0k]
  ------------------
  926|      0|        talloc_free(ctx->sent_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  927|  65.0k|    ctx->num_sent_packets = 0;
  928|       |
  929|  65.0k|    for (int n = 0; n < ctx->num_requeue_packets; n++)
  ------------------
  |  Branch (929:21): [True: 0, False: 65.0k]
  ------------------
  930|      0|        talloc_free(ctx->requeue_packets[n]);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  931|  65.0k|    ctx->num_requeue_packets = 0;
  932|       |
  933|  65.0k|    reset_avctx(vd);
  934|  65.0k|}
vd_lavc.c:reset_avctx:
  905|  97.5k|{
  906|  97.5k|    vd_ffmpeg_ctx *ctx = vd->priv;
  907|       |
  908|  97.5k|    if (ctx->avctx && avcodec_is_open(ctx->avctx))
  ------------------
  |  Branch (908:9): [True: 65.0k, False: 32.5k]
  |  Branch (908:23): [True: 65.0k, False: 0]
  ------------------
  909|  65.0k|        avcodec_flush_buffers(ctx->avctx);
  910|  97.5k|    ctx->flushing = false;
  911|  97.5k|    ctx->hwdec_request_reinit = false;
  912|       |    // Wait for the first keyframe after reset to ensure the decoder state is
  913|       |    // valid. Seeking should already jump to a keyframe, so this is safe.
  914|  97.5k|    ctx->wait_for_keyframe = ctx->use_hwdec ? HWDEC_WAIT_KEYFRAME_COUNT : 0;
  ------------------
  |  |   69|      0|#define HWDEC_WAIT_KEYFRAME_COUNT 96
  ------------------
  |  Branch (914:30): [True: 0, False: 97.5k]
  ------------------
  915|  97.5k|}
vd_lavc.c:vd_lavc_process:
 1467|  2.56M|{
 1468|  2.56M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1469|       |
 1470|  2.56M|    lavc_process(vd, &ctx->state, send_packet, receive_frame);
 1471|  2.56M|}
vd_lavc.c:send_packet:
 1224|   845k|{
 1225|   845k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1226|   845k|    AVCodecContext *avctx = ctx->avctx;
 1227|       |
 1228|   845k|    if (ctx->num_requeue_packets && ctx->requeue_packets[0] != pkt)
  ------------------
  |  Branch (1228:9): [True: 0, False: 845k]
  |  Branch (1228:37): [True: 0, False: 0]
  ------------------
 1229|      0|        return AVERROR(EAGAIN); // cannot consume the packet
 1230|       |
 1231|   845k|    if (ctx->hwdec_failed)
  ------------------
  |  Branch (1231:9): [True: 0, False: 845k]
  ------------------
 1232|      0|        return AVERROR(EAGAIN);
 1233|       |
 1234|   845k|    if (!ctx->avctx)
  ------------------
  |  Branch (1234:9): [True: 0, False: 845k]
  ------------------
 1235|      0|        return AVERROR_EOF;
 1236|       |
 1237|   845k|    prepare_decoding(vd);
 1238|       |
 1239|   845k|    if (ctx->wait_for_keyframe > 0 && pkt) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 845k]
  |  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|   845k|    if (avctx->skip_frame == AVDISCARD_ALL)
  ------------------
  |  Branch (1248:9): [True: 0, False: 845k]
  ------------------
 1249|      0|        return 0;
 1250|       |
 1251|   845k|    mp_set_av_packet(ctx->avpkt, pkt, &ctx->codec_timebase);
 1252|       |
 1253|   845k|    int ret = avcodec_send_packet(avctx, pkt ? ctx->avpkt : NULL);
  ------------------
  |  Branch (1253:42): [True: 812k, False: 32.5k]
  ------------------
 1254|   845k|    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
  ------------------
  |  Branch (1254:9): [True: 0, False: 845k]
  |  Branch (1254:35): [True: 0, False: 845k]
  ------------------
 1255|      0|        return ret;
 1256|       |
 1257|   845k|    if (ctx->hw_probing && ctx->num_sent_packets < 32 &&
  ------------------
  |  Branch (1257:9): [True: 0, False: 845k]
  |  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|   845k|    if (ret < 0)
  ------------------
  |  Branch (1264:9): [True: 0, False: 845k]
  ------------------
 1265|      0|        handle_err(vd);
 1266|   845k|    return ret;
 1267|   845k|}
vd_lavc.c:prepare_decoding:
 1184|  3.38M|{
 1185|  3.38M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1186|  3.38M|    AVCodecContext *avctx = ctx->avctx;
 1187|  3.38M|    struct vd_lavc_params *opts = ctx->opts;
 1188|       |
 1189|  3.38M|    if (!avctx)
  ------------------
  |  Branch (1189:9): [True: 0, False: 3.38M]
  ------------------
 1190|      0|        return;
 1191|       |
 1192|  3.38M|    int drop = ctx->framedrop_flags;
 1193|  3.38M|    if (drop == 1) {
  ------------------
  |  Branch (1193:9): [True: 0, False: 3.38M]
  ------------------
 1194|      0|        avctx->skip_frame = opts->framedrop;    // normal framedrop
 1195|  3.38M|    } else if (drop == 2) {
  ------------------
  |  Branch (1195:16): [True: 0, False: 3.38M]
  ------------------
 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|  3.38M|    } else {
 1201|  3.38M|        avctx->skip_frame = ctx->skip_frame;    // normal playback
 1202|  3.38M|    }
 1203|       |
 1204|  3.38M|    if (ctx->hwdec_request_reinit)
  ------------------
  |  Branch (1204:9): [True: 0, False: 3.38M]
  ------------------
 1205|      0|        reset_avctx(vd);
 1206|  3.38M|}
vd_lavc.c:receive_frame:
 1345|  2.53M|{
 1346|  2.53M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1347|       |
 1348|  2.53M|    int ret = decode_frame(vd);
 1349|       |
 1350|  2.53M|    if (ctx->hwdec_failed) {
  ------------------
  |  Branch (1350:9): [True: 0, False: 2.53M]
  ------------------
 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|  2.53M|    if (ret == AVERROR(EAGAIN) && ctx->num_requeue_packets)
  ------------------
  |  Branch (1377:9): [True: 1.69M, False: 845k]
  |  Branch (1377:35): [True: 0, False: 1.69M]
  ------------------
 1378|      0|        return 0; // force retry, so send_queued_packet() gets called
 1379|       |
 1380|  2.53M|    if (ctx->num_delay_queue <= ctx->max_delay_queue && ret != AVERROR_EOF)
  ------------------
  |  Branch (1380:9): [True: 1.72M, False: 812k]
  |  Branch (1380:57): [True: 1.69M, False: 32.5k]
  ------------------
 1381|  1.69M|        return ret;
 1382|       |
 1383|   845k|    if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1383:9): [True: 32.5k, False: 812k]
  ------------------
 1384|  32.5k|        return ret;
 1385|       |
 1386|   812k|    struct mp_image *res = ctx->delay_queue[0];
 1387|   812k|    MP_TARRAY_REMOVE_AT(ctx->delay_queue, ctx->num_delay_queue, 0);
  ------------------
  |  |  143|   812k|    do {                                            \
  |  |  144|   812k|        size_t at_ = (at);                          \
  |  |  145|   812k|        assert(at_ < (idxvar));                     \
  |  |  146|   812k|        memmove((p) + at_, (p) + at_ + 1,           \
  |  |  147|   812k|                ((idxvar) - at_ - 1) * sizeof((p)[0])); \
  |  |  148|   812k|        (idxvar)--;                                 \
  |  |  149|   812k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (149:14): [Folded, False: 812k]
  |  |  ------------------
  ------------------
  |  Branch (1387:5): [True: 812k, False: 0]
  ------------------
 1388|       |
 1389|   812k|    res = res ? mp_img_swap_to_native(res) : NULL;
  ------------------
  |  Branch (1389:11): [True: 812k, False: 0]
  ------------------
 1390|   812k|    if (!res)
  ------------------
  |  Branch (1390:9): [True: 0, False: 812k]
  ------------------
 1391|      0|        return AVERROR_UNKNOWN;
 1392|       |
 1393|   812k|    if (ctx->use_hwdec && ctx->hwdec.copying && res->hwctx) {
  ------------------
  |  Branch (1393:9): [True: 0, False: 812k]
  |  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|   812k|    if (!ctx->hwdec_notified) {
  ------------------
  |  Branch (1405:9): [True: 32.5k, False: 780k]
  ------------------
 1406|  32.5k|        if (ctx->use_hwdec) {
  ------------------
  |  Branch (1406:13): [True: 0, False: 32.5k]
  ------------------
 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|  32.5k|        } else {
 1410|  32.5k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
 1411|  32.5k|        }
 1412|  32.5k|        ctx->hwdec_notified = true;
 1413|  32.5k|    }
 1414|       |
 1415|   812k|    if (ctx->hw_probing) {
  ------------------
  |  Branch (1415:9): [True: 0, False: 812k]
  ------------------
 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|   812k|    *out_frame = MAKE_FRAME(MP_FRAME_VIDEO, res);
  ------------------
  |  |   57|   812k|#define MAKE_FRAME(type, frame) ((struct mp_frame){(type), (frame)})
  ------------------
 1423|   812k|    return 0;
 1424|   812k|}
vd_lavc.c:decode_frame:
 1283|  2.53M|{
 1284|  2.53M|    vd_ffmpeg_ctx *ctx = vd->priv;
 1285|  2.53M|    AVCodecContext *avctx = ctx->avctx;
 1286|       |
 1287|  2.53M|    if (!avctx || ctx->force_eof)
  ------------------
  |  Branch (1287:9): [True: 0, False: 2.53M]
  |  Branch (1287:19): [True: 0, False: 2.53M]
  ------------------
 1288|      0|        return AVERROR_EOF;
 1289|       |
 1290|  2.53M|    prepare_decoding(vd);
 1291|       |
 1292|       |    // Re-send old packets (typically after a hwdec fallback during init).
 1293|  2.53M|    if (ctx->num_requeue_packets)
  ------------------
  |  Branch (1293:9): [True: 0, False: 2.53M]
  ------------------
 1294|      0|        send_queued_packet(vd);
 1295|       |
 1296|  2.53M|    int ret = avcodec_receive_frame(avctx, ctx->pic);
 1297|  2.53M|    if (ret < 0) {
  ------------------
  |  Branch (1297:9): [True: 1.72M, False: 812k]
  ------------------
 1298|  1.72M|        if (ret == AVERROR_EOF) {
  ------------------
  |  Branch (1298:13): [True: 32.5k, False: 1.69M]
  ------------------
 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|  32.5k|            if (!ctx->num_delay_queue)
  ------------------
  |  Branch (1303:17): [True: 32.5k, False: 0]
  ------------------
 1304|  32.5k|                reset_avctx(vd);
 1305|  1.69M|        } else if (ret == AVERROR(EAGAIN)) {
  ------------------
  |  Branch (1305:20): [True: 1.69M, False: 0]
  ------------------
 1306|       |            // just retry after caller writes a packet
 1307|  1.69M|        } else {
 1308|      0|            handle_err(vd);
 1309|      0|        }
 1310|  1.72M|        return ret;
 1311|  1.72M|    }
 1312|       |
 1313|   812k|    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|   812k|    mp_assert(ctx->pic->buf[0]);
  ------------------
  |  |   41|   812k|#define mp_assert assert
  ------------------
  |  Branch (1317:5): [True: 812k, False: 0]
  ------------------
 1318|       |
 1319|   812k|    struct mp_image *mpi = mp_image_from_av_frame(ctx->pic);
 1320|   812k|    if (!mpi) {
  ------------------
  |  Branch (1320:9): [True: 0, False: 812k]
  ------------------
 1321|      0|        av_frame_unref(ctx->pic);
 1322|      0|        return ret;
 1323|      0|    }
 1324|       |
 1325|   812k|    if (mpi->imgfmt == IMGFMT_CUDA && !mpi->planes[0]) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 812k]
  |  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|   812k|    ctx->hwdec_fail_count = 0;
 1333|       |
 1334|   812k|    mpi->pts = mp_pts_from_av(ctx->pic->pts, &ctx->codec_timebase);
 1335|   812k|    mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);
 1336|   812k|    mpi->pkt_duration = mp_pts_from_av(ctx->pic->duration, &ctx->codec_timebase);
 1337|       |
 1338|   812k|    av_frame_unref(ctx->pic);
 1339|       |
 1340|   812k|    MP_TARRAY_APPEND(ctx, ctx->delay_queue, ctx->num_delay_queue, mpi);
  ------------------
  |  |  105|   812k|    do {                                            \
  |  |  106|   812k|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|   812k|    do {                                            \
  |  |  |  |   97|   812k|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|   812k|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|   812k|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|   812k|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 32.5k, False: 780k]
  |  |  |  |  ------------------
  |  |  |  |   99|   812k|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|  32.5k|    do {                                                        \
  |  |  |  |  |  |   89|  32.5k|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|  32.5k|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  32.5k|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|  32.5k|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  32.5k|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|  32.5k|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|  32.5k|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 32.5k]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|   812k|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 812k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|   812k|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|   812k|        (idxvar)++;                                 \
  |  |  109|   812k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 812k]
  |  |  ------------------
  ------------------
 1341|   812k|    return ret;
 1342|   812k|}
vd_lavc.c:select_and_set_hwdec:
  504|  32.5k|{
  505|  32.5k|    vd_ffmpeg_ctx *ctx = vd->priv;
  506|  32.5k|    const char *codec = ctx->codec->codec;
  507|       |
  508|  32.5k|    m_config_cache_update(ctx->hwdec_opts_cache);
  509|       |
  510|  32.5k|    struct hwdec_info *hwdecs = NULL;
  511|  32.5k|    int num_hwdecs = 0;
  512|  32.5k|    add_all_hwdec_methods(&hwdecs, &num_hwdecs);
  513|       |
  514|  32.5k|    char **hwdec_api = ctx->hwdec_opts->hwdec_api;
  515|  32.5k|    for (int i = 0; hwdec_api && hwdec_api[i]; i++) {
  ------------------
  |  Branch (515:21): [True: 32.5k, False: 0]
  |  Branch (515:34): [True: 32.5k, False: 0]
  ------------------
  516|  32.5k|        bstr opt = bstr0(hwdec_api[i]);
  517|       |
  518|  32.5k|        bool hwdec_requested = !bstr_equals0(opt, "no");
  519|  32.5k|        bool hwdec_auto_safe = bstr_equals0(opt, "auto") ||
  ------------------
  |  Branch (519:32): [True: 0, False: 32.5k]
  ------------------
  520|  32.5k|                            bstr_equals0(opt, "auto-safe") ||
  ------------------
  |  Branch (520:29): [True: 0, False: 32.5k]
  ------------------
  521|  32.5k|                            bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (521:29): [True: 0, False: 32.5k]
  ------------------
  522|  32.5k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (522:29): [True: 0, False: 32.5k]
  ------------------
  523|  32.5k|                            bstr_equals0(opt, "yes") ||
  ------------------
  |  Branch (523:29): [True: 0, False: 32.5k]
  ------------------
  524|  32.5k|                            bstr_equals0(opt, "");
  ------------------
  |  Branch (524:29): [True: 0, False: 32.5k]
  ------------------
  525|  32.5k|        bool hwdec_auto_unsafe = bstr_equals0(opt, "auto-unsafe");
  526|  32.5k|        bool hwdec_auto_copy = bstr_equals0(opt, "auto-copy") ||
  ------------------
  |  Branch (526:32): [True: 0, False: 32.5k]
  ------------------
  527|  32.5k|                            bstr_equals0(opt, "auto-copy-safe") ||
  ------------------
  |  Branch (527:29): [True: 0, False: 32.5k]
  ------------------
  528|  32.5k|                            bstr_equals0(opt, "auto-copy-unsafe");
  ------------------
  |  Branch (528:29): [True: 0, False: 32.5k]
  ------------------
  529|  32.5k|        bool hwdec_auto = hwdec_auto_unsafe || hwdec_auto_copy || hwdec_auto_safe;
  ------------------
  |  Branch (529:27): [True: 0, False: 32.5k]
  |  Branch (529:48): [True: 0, False: 32.5k]
  |  Branch (529:67): [True: 0, False: 32.5k]
  ------------------
  530|       |
  531|  32.5k|        if (!hwdec_requested) {
  ------------------
  |  Branch (531:13): [True: 32.5k, False: 0]
  ------------------
  532|  32.5k|            MP_VERBOSE(vd, "No hardware decoding requested.\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  533|  32.5k|            break;
  534|  32.5k|        } else if (!hwdec_codec_allowed(vd, codec)) {
  ------------------
  |  Branch (534:20): [True: 0, False: 0]
  ------------------
  535|      0|            MP_VERBOSE(vd, "Not trying to use hardware decoding: codec %s is not "
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  536|      0|                    "on whitelist.\n", codec);
  537|      0|            break;
  538|      0|        } else if (ctx->force_swdec) {
  ------------------
  |  Branch (538:20): [True: 0, False: 0]
  ------------------
  539|      0|            MP_VERBOSE(vd, "Not trying to use hardware decoding: disallowed\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  540|      0|            break;
  541|      0|        } else {
  542|      0|            bool hwdec_name_supported = false;  // relevant only if !hwdec_auto
  543|      0|            for (int n = 0; n < num_hwdecs; n++) {
  ------------------
  |  Branch (543:29): [True: 0, False: 0]
  ------------------
  544|      0|                struct hwdec_info *hwdec = &hwdecs[n];
  545|       |
  546|      0|                if (!hwdec_auto && !(bstr_equals0(opt, hwdec->method_name) ||
  ------------------
  |  Branch (546:21): [True: 0, False: 0]
  |  Branch (546:38): [True: 0, False: 0]
  ------------------
  547|      0|                                    bstr_equals0(opt, hwdec->name)))
  ------------------
  |  Branch (547:37): [True: 0, False: 0]
  ------------------
  548|      0|                    continue;
  549|      0|                hwdec_name_supported = true;
  550|       |
  551|      0|                bool already_attempted = false;
  552|      0|                for (int j = 0; j < ctx->num_attempted_hwdecs; j++) {
  ------------------
  |  Branch (552:33): [True: 0, False: 0]
  ------------------
  553|      0|                    if (bstr_equals0(ctx->attempted_hwdecs[j], hwdec->name)) {
  ------------------
  |  Branch (553:25): [True: 0, False: 0]
  ------------------
  554|      0|                        MP_DBG(vd, "Skipping previously attempted hwdec: %s\n",
  ------------------
  |  |   93|      0|#define MP_DBG(obj, ...)        MP_MSG(obj, MSGL_DEBUG, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  555|      0|                               hwdec->name);
  556|      0|                        already_attempted = true;
  557|      0|                        break;
  558|      0|                    }
  559|      0|                }
  560|      0|                if (already_attempted)
  ------------------
  |  Branch (560:21): [True: 0, False: 0]
  ------------------
  561|      0|                    continue;
  562|       |
  563|      0|                const char *hw_codec = mp_codec_from_av_codec_id(hwdec->codec->id);
  564|      0|                if (!hw_codec || strcmp(hw_codec, codec) != 0)
  ------------------
  |  Branch (564:21): [True: 0, False: 0]
  |  Branch (564:34): [True: 0, False: 0]
  ------------------
  565|      0|                    continue;
  566|       |
  567|      0|                if (hwdec_auto_safe && !(hwdec->flags & HWDEC_FLAG_WHITELIST))
  ------------------
  |  Branch (567:21): [True: 0, False: 0]
  |  Branch (567:40): [True: 0, False: 0]
  ------------------
  568|      0|                    continue;
  569|       |
  570|      0|                MP_VERBOSE(vd, "Looking at hwdec %s...\n", hwdec->name);
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  571|       |
  572|       |                /*
  573|       |                 * Past this point, any kind of failure that results in us
  574|       |                 * looking for a new hwdec should not lead to use trying this
  575|       |                 * hwdec again - so add it to the list, regardless of whether
  576|       |                 * initialisation will succeed or not.
  577|       |                 */
  578|      0|                MP_TARRAY_APPEND(ctx, ctx->attempted_hwdecs,
  ------------------
  |  |  105|      0|    do {                                            \
  |  |  106|      0|        MP_TARRAY_GROW(ctx, p, idxvar);             \
  |  |  ------------------
  |  |  |  |   96|      0|    do {                                            \
  |  |  |  |   97|      0|        size_t nextidx_ = (nextidx);                \
  |  |  |  |   98|      0|        if (nextidx_ >= MP_TALLOC_AVAIL(p))         \
  |  |  |  |  ------------------
  |  |  |  |  |  |   84|      0|#define MP_TALLOC_AVAIL(p) (talloc_get_size(p) / sizeof((p)[0]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   45|      0|#define talloc_get_size                 ta_get_size
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (98:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   99|      0|            MP_RESIZE_ARRAY(ctx, p, ta_calc_prealloc_elems(nextidx_)); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   88|      0|    do {                                                        \
  |  |  |  |  |  |   89|      0|        (p) = ta_xrealloc_size(ctx, p,                          \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  158|      0|#define ta_xrealloc_size(...)   ta_dbg_set_loc(ta_xrealloc_size(__VA_ARGS__), TA_LOC)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|      0|#define TA_LOC __FILE__ ":" TA_STRINGIFY(__LINE__)
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define TA_STRINGIFY(x) TA_STRINGIFY_(x)
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define TA_STRINGIFY_(x) # x
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   90|      0|                    ta_calc_array_size(sizeof((p)[0]), count)); \
  |  |  |  |  |  |   91|      0|    } while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (91:14): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  100|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (100:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|        (p)[(idxvar)] = (__VA_ARGS__);              \
  |  |  108|      0|        (idxvar)++;                                 \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  579|      0|                                 ctx->num_attempted_hwdecs,
  580|      0|                                 bstrdup(ctx, bstr0(hwdec->name)));
  581|       |
  582|      0|                if (hwdec_auto_copy && !hwdec->copying) {
  ------------------
  |  Branch (582:21): [True: 0, False: 0]
  |  Branch (582:40): [True: 0, False: 0]
  ------------------
  583|      0|                    MP_VERBOSE(vd, "Not using this for auto-copy.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  584|      0|                    continue;
  585|      0|                }
  586|       |
  587|      0|                if (hwdec->lavc_device) {
  ------------------
  |  Branch (587:21): [True: 0, False: 0]
  ------------------
  588|      0|                    ctx->hwdec_dev = hwdec_create_dev(vd, hwdec, hwdec_auto);
  589|      0|                    if (!ctx->hwdec_dev) {
  ------------------
  |  Branch (589:25): [True: 0, False: 0]
  ------------------
  590|      0|                        MP_VERBOSE(vd, "Could not create device.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  591|      0|                        continue;
  592|      0|                    }
  593|       |
  594|      0|                    const struct hwcontext_fns *fns =
  595|      0|                                hwdec_get_hwcontext_fns(hwdec->lavc_device);
  596|      0|                    if (fns && fns->is_codec_allowed &&
  ------------------
  |  Branch (596:25): [True: 0, False: 0]
  |  Branch (596:32): [True: 0, False: 0]
  ------------------
  597|      0|                        !fns->is_codec_allowed(ctx->hwdec_dev, hwdec->codec->id))
  ------------------
  |  Branch (597:25): [True: 0, False: 0]
  ------------------
  598|      0|                    {
  599|      0|                        MP_WARN(vd, "Hardware decoding of '%s' is disabled on this "
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  600|      0|                                    "device.\n", codec);
  601|      0|                        av_buffer_unref(&ctx->hwdec_dev);
  602|      0|                        continue;
  603|      0|                    }
  604|      0|                    if (fns && fns->is_emulated && fns->is_emulated(ctx->hwdec_dev)) {
  ------------------
  |  Branch (604:25): [True: 0, False: 0]
  |  Branch (604:32): [True: 0, False: 0]
  |  Branch (604:52): [True: 0, False: 0]
  ------------------
  605|      0|                        if (hwdec_auto) {
  ------------------
  |  Branch (605:29): [True: 0, False: 0]
  ------------------
  606|      0|                            MP_VERBOSE(vd, "Not using emulated API.\n");
  ------------------
  |  |   92|      0|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  607|      0|                            av_buffer_unref(&ctx->hwdec_dev);
  608|      0|                            continue;
  609|      0|                        }
  610|      0|                        MP_WARN(vd, "Using emulated hardware decoding API.\n");
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  611|      0|                    }
  612|      0|                } else if (!hwdec->copying) {
  ------------------
  |  Branch (612:28): [True: 0, False: 0]
  ------------------
  613|       |                    // Most likely METHOD_INTERNAL, which often use delay-loaded
  614|       |                    // VO support as well.
  615|      0|                    if (ctx->hwdec_devs) {
  ------------------
  |  Branch (615:25): [True: 0, False: 0]
  ------------------
  616|      0|                        struct hwdec_imgfmt_request params = {
  617|      0|                            .imgfmt = pixfmt2imgfmt(hwdec->pix_fmt),
  618|      0|                            .probing = hwdec_auto,
  619|      0|                        };
  620|      0|                        hwdec_devices_request_for_img_fmt(
  621|      0|                            ctx->hwdec_devs, &params);
  622|      0|                    }
  623|      0|                }
  624|       |
  625|      0|                ctx->use_hwdec = true;
  626|      0|                ctx->hwdec = *hwdec;
  627|      0|                break;
  628|      0|            }
  629|      0|            if (ctx->use_hwdec)
  ------------------
  |  Branch (629:17): [True: 0, False: 0]
  ------------------
  630|      0|                break;
  631|      0|            else if (!hwdec_auto && !hwdec_name_supported)
  ------------------
  |  Branch (631:22): [True: 0, False: 0]
  |  Branch (631:37): [True: 0, False: 0]
  ------------------
  632|      0|                MP_WARN(vd, "Unsupported hwdec: %.*s\n", BSTR_P(opt));
  ------------------
  |  |   90|      0|#define MP_WARN(obj, ...)       MP_MSG(obj, MSGL_WARN, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|      0|        }
  634|  32.5k|    }
  635|  32.5k|    talloc_free(hwdecs);
  ------------------
  |  |   47|  32.5k|#define talloc_free                     ta_free
  ------------------
  636|       |
  637|       |
  638|  32.5k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (638:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    } 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|  32.5k|        if (ctx->hwdec_opts->software_fallback == INT_MAX) {
  ------------------
  |  Branch (646:13): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|        } else {
  650|  32.5k|            MP_VERBOSE(vd, "Using software decoding.\n");
  ------------------
  |  |   92|  32.5k|#define MP_VERBOSE(obj, ...)    MP_MSG(obj, MSGL_V, __VA_ARGS__)
  |  |  ------------------
  |  |  |  |   86|  32.5k|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  ------------------
  651|  32.5k|        }
  652|  32.5k|    }
  653|  32.5k|}
vd_lavc.c:init_avctx:
  728|  32.5k|{
  729|  32.5k|    vd_ffmpeg_ctx *ctx = vd->priv;
  730|  32.5k|    struct vd_lavc_params *lavc_param = ctx->opts;
  731|  32.5k|    struct mp_codec_params *c = ctx->codec;
  732|       |
  733|  32.5k|    m_config_cache_update(ctx->opts_cache);
  734|       |
  735|  32.5k|    mp_assert(!ctx->avctx);
  ------------------
  |  |   41|  32.5k|#define mp_assert assert
  ------------------
  |  Branch (735:5): [True: 32.5k, False: 0]
  ------------------
  736|       |
  737|  32.5k|    const AVCodec *lavc_codec = NULL;
  738|       |
  739|  32.5k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (739:9): [True: 0, False: 32.5k]
  ------------------
  740|      0|        lavc_codec = ctx->hwdec.codec;
  741|  32.5k|    } else {
  742|  32.5k|        lavc_codec = avcodec_find_decoder_by_name(ctx->decoder);
  743|  32.5k|    }
  744|  32.5k|    if (!lavc_codec)
  ------------------
  |  Branch (744:9): [True: 0, False: 32.5k]
  ------------------
  745|      0|        return;
  746|       |
  747|  32.5k|    const AVCodecDescriptor *desc = avcodec_descriptor_get(lavc_codec->id);
  748|  32.5k|    ctx->intra_only = desc && (desc->props & AV_CODEC_PROP_INTRA_ONLY);
  ------------------
  |  Branch (748:23): [True: 32.5k, False: 0]
  |  Branch (748:31): [True: 0, False: 32.5k]
  ------------------
  749|       |
  750|  32.5k|    ctx->codec_timebase = mp_get_codec_timebase(ctx->codec);
  751|       |
  752|  32.5k|    ctx->hwdec_failed = false;
  753|  32.5k|    ctx->hwdec_request_reinit = false;
  754|  32.5k|    ctx->avctx = avcodec_alloc_context3(lavc_codec);
  755|  32.5k|    AVCodecContext *avctx = ctx->avctx;
  756|  32.5k|    if (!ctx->avctx)
  ------------------
  |  Branch (756:9): [True: 0, False: 32.5k]
  ------------------
  757|      0|        goto error;
  758|  32.5k|    avctx->codec_type = AVMEDIA_TYPE_VIDEO;
  759|  32.5k|    avctx->codec_id = lavc_codec->id;
  760|  32.5k|    avctx->pkt_timebase = ctx->codec_timebase;
  761|       |
  762|  32.5k|    ctx->pic = av_frame_alloc();
  763|  32.5k|    if (!ctx->pic)
  ------------------
  |  Branch (763:9): [True: 0, False: 32.5k]
  ------------------
  764|      0|        goto error;
  765|       |
  766|  32.5k|    ctx->avpkt = av_packet_alloc();
  767|  32.5k|    if (!ctx->avpkt)
  ------------------
  |  Branch (767:9): [True: 0, False: 32.5k]
  ------------------
  768|      0|        goto error;
  769|       |
  770|  32.5k|    int threads = lavc_param->threads;
  771|  32.5k|    if (ctx->use_hwdec) {
  ------------------
  |  Branch (771:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    mp_set_avcodec_threads(vd->log, avctx, threads);
  820|       |
  821|  32.5k|    if (!ctx->use_hwdec && ctx->vo && lavc_param->dr) {
  ------------------
  |  Branch (821:9): [True: 32.5k, False: 0]
  |  Branch (821:28): [True: 32.5k, False: 0]
  |  Branch (821:39): [True: 32.5k, False: 0]
  ------------------
  822|  32.5k|        avctx->opaque = vd;
  823|  32.5k|        avctx->get_buffer2 = get_buffer2_direct;
  824|  32.5k|    }
  825|       |
  826|  32.5k|    avctx->flags |= lavc_param->bitexact ? AV_CODEC_FLAG_BITEXACT : 0;
  ------------------
  |  Branch (826:21): [True: 0, False: 32.5k]
  ------------------
  827|  32.5k|    avctx->flags2 |= lavc_param->fast ? AV_CODEC_FLAG2_FAST : 0;
  ------------------
  |  Branch (827:22): [True: 0, False: 32.5k]
  ------------------
  828|       |
  829|  32.5k|    if (lavc_param->show_all)
  ------------------
  |  Branch (829:9): [True: 0, False: 32.5k]
  ------------------
  830|      0|        avctx->flags |= AV_CODEC_FLAG_OUTPUT_CORRUPT;
  831|       |
  832|  32.5k|    avctx->skip_loop_filter = lavc_param->skip_loop_filter;
  833|  32.5k|    avctx->skip_idct = lavc_param->skip_idct;
  834|  32.5k|    avctx->skip_frame = lavc_param->skip_frame;
  835|  32.5k|    avctx->apply_cropping = lavc_param->apply_cropping;
  836|       |
  837|  32.5k|    if (lavc_codec->id == AV_CODEC_ID_H264 && lavc_param->old_x264)
  ------------------
  |  Branch (837:9): [True: 0, False: 32.5k]
  |  Branch (837:47): [True: 0, False: 0]
  ------------------
  838|      0|        av_opt_set(avctx, "x264_build", "150", AV_OPT_SEARCH_CHILDREN);
  839|       |
  840|  32.5k|    switch(ctx->opts->film_grain) {
  841|      0|    case 0: /*CPU*/
  ------------------
  |  Branch (841:5): [True: 0, False: 32.5k]
  ------------------
  842|       |        // default lavc flags handle film grain within the decoder.
  843|      0|        break;
  844|      0|    case 1: /*GPU*/
  ------------------
  |  Branch (844:5): [True: 0, False: 32.5k]
  ------------------
  845|      0|        if (!ctx->vo ||
  ------------------
  |  Branch (845:13): [True: 0, False: 0]
  ------------------
  846|      0|            (ctx->vo && !(ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))) {
  ------------------
  |  Branch (846:14): [True: 0, False: 0]
  |  Branch (846:25): [True: 0, False: 0]
  ------------------
  847|      0|            MP_MSG(vd, ctx->vo ? MSGL_WARN : MSGL_V,
  ------------------
  |  |   86|      0|#define MP_MSG(obj, lev, ...)   mp_msg((obj)->log, lev, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (86:52): [True: 0, False: 0]
  |  |  |  Branch (86:57): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  848|      0|                   "GPU film grain requested, but VO %s, expect wrong output.\n",
  849|      0|                   ctx->vo ?
  850|      0|                   "does not support applying film grain" :
  851|      0|                   "is not available at decoder initialization to verify support");
  852|      0|        }
  853|       |
  854|      0|        avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
  855|      0|        break;
  856|  32.5k|    default:
  ------------------
  |  Branch (856:5): [True: 32.5k, False: 0]
  ------------------
  857|  32.5k|        if (ctx->vo && (ctx->vo->driver->caps & VO_CAP_FILM_GRAIN))
  ------------------
  |  Branch (857:13): [True: 32.5k, False: 0]
  |  Branch (857:24): [True: 0, False: 32.5k]
  ------------------
  858|      0|            avctx->export_side_data |= AV_CODEC_EXPORT_DATA_FILM_GRAIN;
  859|       |
  860|  32.5k|        break;
  861|  32.5k|    }
  862|       |
  863|  32.5k|    mp_set_avopts(vd->log, avctx, lavc_param->avopts);
  864|       |
  865|       |    // Do this after the above avopt handling in case it changes values
  866|  32.5k|    ctx->skip_frame = avctx->skip_frame;
  867|       |
  868|  32.5k|    if (mp_set_avctx_codec_headers(avctx, c) < 0) {
  ------------------
  |  Branch (868:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  874|  32.5k|    if (avctx->width > 8192 || avctx->height > 8192) {
  ------------------
  |  Branch (874:9): [True: 0, False: 32.5k]
  |  Branch (874:32): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    avctx->max_pixels = 2048 * 2048;
  879|  32.5k|#endif
  880|       |
  881|       |    /* open it */
  882|  32.5k|    if (avcodec_open2(avctx, lavc_codec, NULL) < 0)
  ------------------
  |  Branch (882:9): [True: 0, False: 32.5k]
  ------------------
  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|  32.5k|    if (lavc_codec->id == AV_CODEC_ID_H264 && c->first_packet) {
  ------------------
  |  Branch (889:9): [True: 0, False: 32.5k]
  |  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|  32.5k|    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:control:
 1427|   943k|{
 1428|   943k|    vd_ffmpeg_ctx *ctx = vd->priv;
 1429|   943k|    switch (cmd) {
  ------------------
  |  Branch (1429:13): [True: 943k, False: 0]
  ------------------
 1430|   845k|    case VDCTRL_SET_FRAMEDROP:
  ------------------
  |  Branch (1430:5): [True: 845k, False: 97.7k]
  ------------------
 1431|   845k|        ctx->framedrop_flags = *(int *)arg;
 1432|   845k|        return CONTROL_TRUE;
  ------------------
  |  |   96|   845k|#define CONTROL_TRUE 1
  ------------------
 1433|      0|    case VDCTRL_SET_EXTRA_HW_FRAMES:
  ------------------
  |  Branch (1433:5): [True: 0, False: 943k]
  ------------------
 1434|      0|        ctx->extra_hw_frames_hint = *(int *)arg;
 1435|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1436|  32.6k|    case VDCTRL_CHECK_FORCED_EOF: {
  ------------------
  |  Branch (1436:5): [True: 32.6k, False: 910k]
  ------------------
 1437|  32.6k|        *(bool *)arg = ctx->force_eof;
 1438|  32.6k|        return CONTROL_TRUE;
  ------------------
  |  |   96|  32.6k|#define CONTROL_TRUE 1
  ------------------
 1439|      0|    }
 1440|      0|    case VDCTRL_GET_BFRAMES: {
  ------------------
  |  Branch (1440:5): [True: 0, False: 943k]
  ------------------
 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|  65.1k|    case VDCTRL_GET_HWDEC: {
  ------------------
  |  Branch (1447:5): [True: 65.1k, False: 878k]
  ------------------
 1448|  65.1k|        if (!ctx->hwdec_notified)
  ------------------
  |  Branch (1448:13): [True: 32.5k, False: 32.6k]
  ------------------
 1449|  32.5k|            return CONTROL_FALSE;
  ------------------
  |  |   97|  32.5k|#define CONTROL_FALSE 0
  ------------------
 1450|  32.6k|        *(char **)arg = ctx->use_hwdec ? ctx->hwdec.method_name : NULL;
  ------------------
  |  Branch (1450:25): [True: 0, False: 32.6k]
  ------------------
 1451|  32.6k|        return CONTROL_TRUE;
  ------------------
  |  |   96|  32.6k|#define CONTROL_TRUE 1
  ------------------
 1452|  65.1k|    }
 1453|      0|    case VDCTRL_FORCE_HWDEC_FALLBACK:
  ------------------
  |  Branch (1453:5): [True: 0, False: 943k]
  ------------------
 1454|      0|        if (ctx->use_hwdec) {
  ------------------
  |  Branch (1454:13): [True: 0, False: 0]
  ------------------
 1455|      0|            force_fallback(vd);
 1456|      0|            return ctx->avctx ? CONTROL_OK : CONTROL_ERROR;
  ------------------
  |  |   95|      0|#define CONTROL_OK 1
  ------------------
                          return ctx->avctx ? CONTROL_OK : CONTROL_ERROR;
  ------------------
  |  |   99|      0|#define CONTROL_ERROR -2
  ------------------
  |  Branch (1456:20): [True: 0, False: 0]
  ------------------
 1457|      0|        }
 1458|      0|        return CONTROL_FALSE;
  ------------------
  |  |   97|      0|#define CONTROL_FALSE 0
  ------------------
 1459|      0|    case VDCTRL_REINIT:
  ------------------
  |  Branch (1459:5): [True: 0, False: 943k]
  ------------------
 1460|      0|        reinit(vd);
 1461|      0|        return CONTROL_TRUE;
  ------------------
  |  |   96|      0|#define CONTROL_TRUE 1
  ------------------
 1462|   943k|    }
 1463|      0|    return CONTROL_UNKNOWN;
  ------------------
  |  |   98|      0|#define CONTROL_UNKNOWN -1
  ------------------
 1464|   943k|}
vd_lavc.c:reinit:
  696|  32.5k|{
  697|  32.5k|    vd_ffmpeg_ctx *ctx = vd->priv;
  698|       |
  699|  32.5k|    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|  32.5k|    TA_FREEP(&ctx->attempted_hwdecs);
  ------------------
  |  |   81|  32.5k|#define TA_FREEP(pctx) do {talloc_free(*(pctx)); *(pctx) = NULL;} while(0)
  |  |  ------------------
  |  |  |  |   47|  32.5k|#define talloc_free                     ta_free
  |  |  ------------------
  |  |  |  Branch (81:73): [Folded, False: 32.5k]
  |  |  ------------------
  ------------------
  708|  32.5k|    ctx->num_attempted_hwdecs = 0;
  709|  32.5k|    ctx->hwdec_notified = false;
  710|       |
  711|  32.5k|    select_and_set_hwdec(vd);
  712|       |
  713|  32.5k|    bool use_hwdec = ctx->use_hwdec;
  714|  32.5k|    init_avctx(vd);
  715|  32.5k|    if (!ctx->avctx && use_hwdec) {
  ------------------
  |  Branch (715:9): [True: 0, False: 32.5k]
  |  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|  32.5k|    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: 32.5k]
  ------------------
  725|  32.5k|}
vd_lavc.c:add_decoders:
 1550|  32.5k|{
 1551|  32.5k|    mp_add_lavc_decoders(list, AVMEDIA_TYPE_VIDEO);
 1552|  32.5k|}

vf_sub.c:vf_sub_create:
  132|  32.5k|{
  133|  32.5k|    struct mp_filter *f = mp_filter_create(parent, &vf_sub_filter);
  134|  32.5k|    if (!f) {
  ------------------
  |  Branch (134:9): [True: 0, False: 32.5k]
  ------------------
  135|      0|        talloc_free(options);
  ------------------
  |  |   47|      0|#define talloc_free                     ta_free
  ------------------
  136|      0|        return NULL;
  137|      0|    }
  138|       |
  139|  32.5k|    mp_filter_add_pin(f, MP_PIN_IN, "in");
  140|  32.5k|    mp_filter_add_pin(f, MP_PIN_OUT, "out");
  141|       |
  142|  32.5k|    struct priv *priv = f->priv;
  143|  32.5k|    priv->opts = talloc_steal(priv, options);
  ------------------
  |  |   38|  32.5k|#define talloc_steal                    ta_steal
  |  |  ------------------
  |  |  |  |  100|  32.5k|#define ta_steal(ta_parent, ptr) (TA_TYPEOF(ptr))ta_steal_(ta_parent, ptr)
  |  |  ------------------
  ------------------
  144|  32.5k|    priv->pool = mp_image_pool_new(priv);
  145|       |
  146|  32.5k|    return f;
  147|  32.5k|}
vf_sub.c:vf_sub_destroy:
  117|  32.5k|{
  118|  32.5k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
  119|  32.5k|    struct osd_state *osd = info ? info->osd : NULL;
  ------------------
  |  Branch (119:29): [True: 32.5k, False: 0]
  ------------------
  120|  32.5k|    if (osd)
  ------------------
  |  Branch (120:9): [True: 32.5k, False: 0]
  ------------------
  121|  32.5k|        osd_set_render_subs_in_filter(osd, false);
  122|  32.5k|}
vf_sub.c:vf_sub_process:
   53|  1.72M|{
   54|  1.72M|    struct priv *priv = f->priv;
   55|       |
   56|  1.72M|    if (!mp_pin_can_transfer_data(f->ppins[1], f->ppins[0]))
  ------------------
  |  Branch (56:9): [True: 877k, False: 845k]
  ------------------
   57|   877k|        return;
   58|       |
   59|   845k|    struct mp_frame frame = mp_pin_out_read(f->ppins[0]);
   60|       |
   61|   845k|    if (mp_frame_is_signaling(frame)) {
  ------------------
  |  Branch (61:9): [True: 32.5k, False: 812k]
  ------------------
   62|  32.5k|        mp_pin_in_write(f->ppins[1], frame);
   63|  32.5k|        return;
   64|  32.5k|    }
   65|       |
   66|   812k|    struct mp_stream_info *info = mp_filter_find_stream_info(f);
   67|   812k|    struct osd_state *osd = info ? info->osd : NULL;
  ------------------
  |  Branch (67:29): [True: 812k, False: 0]
  ------------------
   68|       |
   69|   812k|    if (!osd)
  ------------------
  |  Branch (69:9): [True: 0, False: 812k]
  ------------------
   70|      0|        goto error;
   71|       |
   72|   812k|    osd_set_render_subs_in_filter(osd, true);
   73|       |
   74|   812k|    if (frame.type != MP_FRAME_VIDEO)
  ------------------
  |  Branch (74:9): [True: 0, False: 812k]
  ------------------
   75|      0|        goto error;
   76|       |
   77|   812k|    struct mp_image *mpi = frame.data;
   78|       |
   79|   812k|    struct mp_osd_res dim = {
   80|   812k|        .w = mpi->w,
   81|   812k|        .h = mpi->h + priv->opts->top_margin + priv->opts->bottom_margin,
   82|   812k|        .mt = priv->opts->top_margin,
   83|   812k|        .mb = priv->opts->bottom_margin,
   84|   812k|        .display_par = mpi->params.p_w / (double)mpi->params.p_h,
   85|   812k|    };
   86|       |
   87|   812k|    if (dim.w != mpi->w || dim.h != mpi->h) {
  ------------------
  |  Branch (87:9): [True: 0, False: 812k]
  |  Branch (87:28): [True: 0, False: 812k]
  ------------------
   88|      0|        struct mp_image *dmpi =
   89|      0|            mp_image_pool_get(priv->pool, mpi->imgfmt, dim.w, dim.h);
   90|      0|        if (!dmpi)
  ------------------
  |  Branch (90:13): [True: 0, False: 0]
  ------------------
   91|      0|            goto error;
   92|      0|        mp_image_copy_attributes(dmpi, mpi);
   93|      0|        int y1 = MP_ALIGN_DOWN(priv->opts->top_margin, mpi->fmt.align_y);
  ------------------
  |  |   54|      0|#define MP_ALIGN_DOWN(x, align) ((x) & ~((align) - 1))
  ------------------
   94|      0|        int y2 = MP_ALIGN_DOWN(y1 + mpi->h, mpi->fmt.align_y);
  ------------------
  |  |   54|      0|#define MP_ALIGN_DOWN(x, align) ((x) & ~((align) - 1))
  ------------------
   95|      0|        struct mp_image cropped = *dmpi;
   96|      0|        mp_image_crop(&cropped, 0, y1, mpi->w, y1 + mpi->h);
   97|      0|        mp_image_copy(&cropped, mpi);
   98|      0|        mp_image_clear(dmpi, 0, 0, dmpi->w, y1);
   99|      0|        mp_image_clear(dmpi, 0, y2, dmpi->w, dim.h);
  100|      0|        mp_frame_unref(&frame);
  101|      0|        mpi = dmpi;
  102|      0|        frame = (struct mp_frame){MP_FRAME_VIDEO, mpi};
  103|      0|    }
  104|       |
  105|   812k|    osd_draw_on_image_p(osd, dim, mpi->pts, OSD_DRAW_SUB_FILTER, priv->pool, mpi);
  106|       |
  107|   812k|    mp_pin_in_write(f->ppins[1], frame);
  108|   812k|    return;
  109|       |
  110|      0|error:
  111|      0|    MP_ERR(f, "unsupported format, missing OSD, or failed allocation\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__)
  |  |  ------------------
  ------------------
  112|      0|    mp_frame_unref(&frame);
  113|      0|    mp_filter_internal_mark_failed(f);
  114|      0|}

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

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

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

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

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

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

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

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

