2015-07-15 12 views
2

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

Я использую SDL2, который использует визуализатор, текстуру для отображения изображения на экран. В соответствии с SDL wiki рендерингом используется ускорение GPU. Но вот проблема. видео играет слишком медленно ... около 0.5fps?

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

Я подумал, что, возможно, BBB не поддерживает ускорение GPU и искал его, но не смог получить ответ. Любая помощь, пожалуйста? Вот мой код с использованием 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; 
} 

ответ

0

Да beaglebone черный делает поддержка GPU аппаратное ускорение,

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

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

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

Процессор: 1 ГГц AM335x ARM® Cortex-A8

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

4 Гб 8-битный EMMC на плате флэш-памяти

3D графический ускоритель

NEON с плавающей точкой акселератора

2x 32-разрядные микроконтроллеры PRU

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