Ejemplo n.º 1
0
void SubtitleFilter::process(Statistics *statistics, VideoFrame *frame)
{
    Q_UNUSED(statistics);
    Q_UNUSED(frame);
    DPTR_D(SubtitleFilter);
    QPainterFilterContext* ctx = static_cast<QPainterFilterContext*>(d.context);
    if (!ctx)
        return;
    if (!ctx->paint_device) {
        qWarning("no paint device!");
        return;
    }
    if (d.player_sub->subtitle()->canRender()) {
        if (frame && frame->timestamp() > 0.0)
            d.player_sub->subtitle()->setTimestamp(frame->timestamp()); //TODO: set to current display video frame's timestamp
        QRect rect;
        /*
         * image quality maybe to low if use video frame resolution for large display.
         * The difference is small if use paint_device size and video frame aspect ratio ~ renderer aspect ratio
         * if use renderer's resolution, we have to map bounding rect from video frame coordinate to renderer's
         */
        //QImage img = d.player_sub->subtitle()->getImage(statistics->video_only.width, statistics->video_only.height, &rect);
        QImage img = d.player_sub->subtitle()->getImage(ctx->paint_device->width(), ctx->paint_device->height(), &rect);
        if (img.isNull())
            return;
        ctx->drawImage(rect, img);
        return;
    }
    ctx->font = d.font;
    ctx->pen.setColor(d.color);
    ctx->rect = d.realRect(ctx->paint_device->width(), ctx->paint_device->height());
    ctx->drawPlainText(ctx->rect, Qt::AlignHCenter | Qt::AlignBottom, d.player_sub->subtitle()->getText());
}
Ejemplo n.º 2
0
void OSDFilterQPainter::process()
{
    if (mShowType == ShowNone)
        return;
    DPTR_D(Filter);
    QPainterFilterContext* ctx = static_cast<QPainterFilterContext*>(d.context);
    //qDebug("ctx=%p tid=%p main tid=%p", ctx, QThread::currentThread(), qApp->thread());
    ctx->drawPlainText(ctx->rect, Qt::AlignCenter, text(d.statistics));
}