Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hooked up VDPAU->OpenGL->OpenCL, new VideoDecoder structure
Requires libglew1.6 As it is not possible to bind an OpenGL texture to both VDPAU and OpenCL simultaneously, bit-blit from VDPAU->OpenGL textures to OpenGL->OpenCL textures
- Loading branch information
Showing
26 changed files
with
1,850 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include "ffmpegvideodecoder.h" | ||
#include "videoconsumer.h" | ||
#include "frame.h" | ||
#include "videosurface.h" | ||
|
||
extern "C" { | ||
#include "libavcodec/avcodec.h" | ||
} | ||
|
||
|
||
bool FFMpegVideoDecoder::Initialize(void) | ||
{ | ||
return true; | ||
} | ||
|
||
VideoSurface *FFMpegVideoDecoder::DecodeFrame(AVFrame *frame) | ||
{ | ||
return NULL; | ||
} | ||
|
||
void FFMpegVideoDecoder::DiscardFrame(VideoSurface *frame) | ||
{ | ||
} | ||
|
||
void FFMpegVideoDecoder::Shutdown(void) | ||
{ | ||
} | ||
|
||
static bool IS_DR1_PIX_FMT(const enum PixelFormat fmt) | ||
{ | ||
switch (fmt) | ||
{ | ||
case PIX_FMT_YUV420P: | ||
case PIX_FMT_YUVJ420P: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
|
||
int get_avf_buffer(struct AVCodecContext *c, AVFrame *pic) | ||
{ | ||
VideoConsumer *nd = (VideoConsumer *)(c->opaque); | ||
(void)nd; | ||
|
||
if (!IS_DR1_PIX_FMT(c->pix_fmt)) | ||
{ | ||
return avcodec_default_get_buffer(c, pic); | ||
} | ||
|
||
VideoFrame *frame = NULL; //= nd->GetNextVideoFrame(); | ||
|
||
if (!frame) | ||
return -1; | ||
|
||
for (int i = 0; i < 3; i++) | ||
{ | ||
pic->data[i] = frame->buf + frame->offsets[i]; | ||
pic->linesize[i] = frame->pitches[i]; | ||
} | ||
|
||
pic->opaque = frame; | ||
pic->type = FF_BUFFER_TYPE_USER; | ||
|
||
pic->age = 256 * 256 * 256 * 64; | ||
|
||
pic->reordered_opaque = c->reordered_opaque; | ||
|
||
return 0; | ||
} | ||
|
||
void release_avf_buffer(struct AVCodecContext *c, AVFrame *pic) | ||
{ | ||
(void)c; | ||
|
||
if (pic->type == FF_BUFFER_TYPE_INTERNAL) | ||
{ | ||
avcodec_default_release_buffer(c, pic); | ||
return; | ||
} | ||
|
||
VideoConsumer *nd = (VideoConsumer *)(c->opaque); | ||
(void)nd; | ||
// if (nd) | ||
// nd->DeLimboFrame((VideoFrame*)pic->opaque); | ||
|
||
assert(pic->type == FF_BUFFER_TYPE_USER); | ||
|
||
for (uint i = 0; i < 4; i++) | ||
pic->data[i] = NULL; | ||
} | ||
|
||
|
||
|
||
/* | ||
* vim:ts=4:sw=4:ai:et:si:sts=4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef _FFMPEGVIDEODECODER_H | ||
#define _FFMPEGVIDEODECODER_H | ||
|
||
#include "videodecoder.h" | ||
#include "openclinterface.h" | ||
#include "videosurface.h" | ||
|
||
extern "C" { | ||
#include "libavcodec/avcodec.h" | ||
} | ||
|
||
class FFMpegVideoDecoder : public VideoDecoder | ||
{ | ||
public: | ||
FFMpegVideoDecoder(OpenCLDevice *dev) : VideoDecoder(dev, true) {}; | ||
~FFMpegVideoDecoder() { Shutdown(); }; | ||
const char *Name(void) { return "FFMpeg"; }; | ||
bool Initialize(void); | ||
VideoSurface *DecodeFrame(AVFrame *frame); | ||
void DiscardFrame(VideoSurface *frame); | ||
void Shutdown(void); | ||
void SetCodec(AVCodec *codec) { m_codecId = codec->id; }; | ||
}; | ||
|
||
int get_avf_buffer(struct AVCodecContext *c, AVFrame *pic); | ||
void release_avf_buffer(struct AVCodecContext *c, AVFrame *pic); | ||
|
||
#endif | ||
|
||
/* | ||
* vim:ts=4:sw=4:ai:et:si:sts=4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.