Поддерживает ли BeagleBone Black аппаратное ускорение графического процессора?

заранее спасибо. Я пытаюсь воспроизвести видео на Beaglebone Black (BBB) ​​производства Texas Instrument. Поскольку есть много хороших руководств по использованию ffmpeg и SDL, я решил использовать его. Получите информацию о видео и кодеке, декодируйте кадры с помощью ffmpeg. Отображение декодированных кадров для мониторинга с помощью SDL.

Я использую SDL2, который использует рендерер, текстуру для отображения изображения на экране. Согласно вики SDL, рендерер использует ускорение графического процессора. Но вот проблема. видео воспроизводится слишком медленно... около 0,5 кадров в секунду?

Поэтому я обратился к SDL1.2, в котором используется программный рендеринг. Он отображает оверлей yuv через оперативную память процессора.

Я подумал, что, возможно, BBB не поддерживает ускорение графического процессора, и погуглил об этом, но не смог получить ответ. Любая помощь, пожалуйста? Вот мой код, использующий SDL2.

 #include <libavutil/frame.h>
 #include <libavutil/avutil.h>
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 #include <libswscale/swscale.h>

 #include <SDL2/SDL.h>
 #include <SDL2/SDL_thread.h>

 #ifdef __MINGW32__
 #undef main /* Prevents SDL from overriding main() */
 #endif

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <errno.h>

int main(int argc, char *argv[]) {

AVFormatContext *pFormatCtx = NULL;
int             i, videoStream;
AVCodecContext  *pCodecCtx = NULL;
AVCodec         *pCodec = NULL;
AVFrame         *pFrame = NULL;
AVPacket        packet;
int             frameFinished;

SDL_Window    *window=NULL;
SDL_Renderer    *renderer=NULL;
SDL_Texture     *bmp=NULL;
SDL_Event       event;

int fbfd, ret;
struct fb_var_screeninfo fbvar;

if(argc < 2) {
  fprintf(stderr, "Usage: test <file>\n");
  exit(1);
}
// Register all formats and codecs
av_register_all();

if(SDL_Init(SDL_INIT_VIDEO)) {
fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
exit(1);
}

// Open video file
if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL)!=0)
return -1; // Couldn't open file

// Retrieve stream information
if(avformat_find_stream_info(pFormatCtx, NULL)<0)
return -1; // Couldn't find stream information

// Dump information about file onto standard error
av_dump_format(pFormatCtx, 0, argv[1], 0);

// Find the first video stream
videoStream=-1;
for(i=0; i<pFormatCtx->nb_streams; i++)
  if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
  videoStream=i;
  break;
}
if(videoStream==-1)
return -1; // Didn't find a video stream

// Get a pointer to the codec context for the video stream
pCodecCtx=pFormatCtx->streams[videoStream]->codec;
// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL) {
fprintf(stderr, "Unsupported codec!\n");
return -1; // Codec not found
}


// Open codec
if( avcodec_open2(pCodecCtx, pCodec, NULL)<0 )
return -1; // Could not open codec

// Allocate video frame
pFrame=av_frame_alloc();


int ctxW= pCodecCtx->width;
int ctxH= pCodecCtx->height;

 window =
  SDL_CreateWindow("test",
    SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, 0, 0,
    SDL_WINDOW_BORDERLESS  SDL_WINDOW_FULLSCREEN_DESKTOP);

 renderer = SDL_CreateRenderer(window, -1, 0);

 // Allocate a place to put our YUV image on that screen
 bmp = SDL_CreateTexture(renderer, 
        SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, 
        pCodecCtx->width, pCodecCtx->height);

 av_init_packet(&packet);

 // Read frames and save first five frames to disk
 while(av_read_frame(pFormatCtx, &packet)>=0) {
  // Is this a packet from the video stream?
   if(packet.stream_index==videoStream) {
  // Decode video frame
    avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);

  // Did we get a video frame?
     if(frameFinished) {
       SDL_UpdateYUVTexture(bmp, NULL, pFrame->data[0], pFrame->linesize[0],
        pFrame->data[1], pFrame->linesize[1],
        pFrame->data[2], pFrame->linesize[2]);
      }

      SDL_RenderClear(renderer);
      SDL_RenderCopy(renderer, bmp, NULL, NULL);
      SDL_RenderPresent(renderer);
   }
  SDL_Delay(15);


SDL_PollEvent(&event);
switch(event.type) {
case SDL_QUIT:
  SDL_Quit();
  exit(0);
  break;
default:
  break;
}


}

// Free the packet that was allocated by av_read_frame
 av_free_packet(&packet);

// Free the YUV frame
av_frame_free(&pFrame);

// Close the codec
avcodec_close(pCodecCtx);

// Close the video file
avformat_close_input(&pFormatCtx);

return 0;
}

person jopyeable    schedule 15.07.2015    source источник


Ответы (1)


Да, beaglebone black поддерживает аппаратное ускорение графического процессора,

по этой ссылке в википедии https://en.wikipedia.org/wiki/BeagleBoard

BBB использует графический процессор PowerVR SGX530, подробности о котором можно найти здесь https://en.wikipedia.org/wiki/PowerVR#Series_5

Это с официального сайта BBB http://beagleboard.org/BLACK.

Процессор: AM335x ARM® Cortex-A8 с тактовой частотой 1 ГГц

512 МБ оперативной памяти DDR3

8-битная встроенная флэш-память eMMC объемом 4 ГБ

Ускоритель 3D-графики

Ускоритель операций с плавающей запятой NEON

2x PRU 32-битных микроконтроллера

Вы также можете проверить REF: BBONEBLK_SRM Справочное руководство по системе BeagleBone Black, версия A5.2.

person Prashant Chikhalkar    schedule 12.08.2015
comment
Знаете ли вы, есть ли у какого-либо из предоставленных изображений поддержка драйвера для него, чтобы приложение openGL могло его использовать? - person Rick; 24.06.2019