0

我在 QT ubuntu 20.04 中构建了一个媒体播放器。媒体还可以,但使用我的播放器,总是蓝色的。像这样:

在此处输入图像描述

播放帧代码是

void QPlayer::recvFrame(AVFrame *frame)
{
    this->context()->functions()->glClearColor(1,1,1,1);
    this->context()->functions()->glClear(GL_TEXTURE_BIT);
    this->context()->functions()->glActiveTexture(GL_TEXTURE0);

    this->context()->functions()->glBindTexture(GL_TEXTURE_2D, id_y);
    this->context()->functions()->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1920, 1080, 0, GL_RED, GL_UNSIGNED_BYTE, frame->data[0]);
    this->context()->functions()->glUniform1i(this->texUniformY, 0);

    this->context()->functions()->glActiveTexture(GL_TEXTURE1);
    this->context()->functions()->glBindTexture(GL_TEXTURE_2D, id_u);
    this->context()->functions()->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1920 / 2, 1080 / 2, 0,  GL_RED, GL_UNSIGNED_BYTE, frame->data[0] + 1920 * 1080);
    this->context()->functions()->glUniform1i(this->texUniformU, 1);

    this->context()->functions()->glActiveTexture(GL_TEXTURE2);
    this->context()->functions()->glBindTexture(GL_TEXTURE_2D, id_v);
    this->context()->functions()->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1920 / 2, 1080 / 2, 0,  GL_RED, GL_UNSIGNED_BYTE, frame->data[0] + 1920 * 1080 + 1920 * 1080 / 4);
    this->context()->functions()->glUniform1i(this->texUniformV, 2);

    this->context()->functions()->glDrawArrays(GL_TRIANGLE_STRIP, 0 , 4);

    this->context()->functions()->glUseProgram(0);
    this->context()->functions()->glFlush();
//    this->frame = frame;

    this->update();

//    printf("recv frame\n");
}
4

0 回答 0