#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include "config.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include "libavutil/common.h"
#include "libavutil/frame.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/avassert.h"
#include "libavformat/avformat.h"
#include "libavformat/internal.h"
#include "libavformat/mux.h"
#include "libavdevice/avdevice.h"
#include "opengl_enc_shaders.h"
Go to the source code of this file.
|
typedef void(APIENTRY * | FF_PFNGLACTIVETEXTUREPROC) (GLenum texture) |
|
typedef void(APIENTRY * | FF_PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers) |
|
typedef void(APIENTRY * | FF_PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers) |
|
typedef void(APIENTRY * | FF_PFNGLBUFFERDATAPROC) (GLenum target, ptrdiff_t size, const GLvoid *data, GLenum usage) |
|
typedef void(APIENTRY * | FF_PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer) |
|
typedef GLint(APIENTRY * | FF_PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const char *name) |
|
typedef void(APIENTRY * | FF_PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index) |
|
typedef void(APIENTRY * | FF_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, uintptr_t pointer) |
|
typedef GLint(APIENTRY * | FF_PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const char *name) |
|
typedef void(APIENTRY * | FF_PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0) |
|
typedef void(APIENTRY * | FF_PFNGLUNIFORM1IPROC) (GLint location, GLint v0) |
|
typedef void(APIENTRY * | FF_PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
|
typedef GLuint(APIENTRY * | FF_PFNGLCREATEPROGRAMPROC) (void) |
|
typedef void(APIENTRY * | FF_PFNGLDELETEPROGRAMPROC) (GLuint program) |
|
typedef void(APIENTRY * | FF_PFNGLUSEPROGRAMPROC) (GLuint program) |
|
typedef void(APIENTRY * | FF_PFNGLLINKPROGRAMPROC) (GLuint program) |
|
typedef void(APIENTRY * | FF_PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params) |
|
typedef void(APIENTRY * | FF_PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, char *infoLog) |
|
typedef void(APIENTRY * | FF_PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader) |
|
typedef GLuint(APIENTRY * | FF_PFNGLCREATESHADERPROC) (GLenum type) |
|
typedef void(APIENTRY * | FF_PFNGLDELETESHADERPROC) (GLuint shader) |
|
typedef void(APIENTRY * | FF_PFNGLCOMPILESHADERPROC) (GLuint shader) |
|
typedef void(APIENTRY * | FF_PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const char **string, const GLint *length) |
|
typedef void(APIENTRY * | FF_PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params) |
|
typedef void(APIENTRY * | FF_PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog) |
|
|
static av_cold int | opengl_prepare_vertex (AVFormatContext *s) |
|
static int | opengl_draw (AVFormatContext *h, void *intput, int repaint, int is_pkt) |
|
static av_cold int | opengl_init_context (OpenGLContext *opengl) |
|
static av_cold void | opengl_deinit_context (OpenGLContext *opengl) |
|
static int | opengl_resize (AVFormatContext *h, int width, int height) |
|
static int | opengl_control_message (AVFormatContext *h, int type, void *data, size_t data_size) |
|
static int av_cold | opengl_load_procedures (OpenGLContext *opengl) |
|
static void | opengl_make_identity (float matrix[16]) |
|
static void | opengl_make_ortho (float matrix[16], float left, float right, float bottom, float top, float nearZ, float farZ) |
|
static av_cold int | opengl_read_limits (AVFormatContext *h) |
|
static const char * | opengl_get_fragment_shader_code (enum AVPixelFormat format) |
|
static int | opengl_type_size (GLenum type) |
|
static av_cold void | opengl_get_texture_params (OpenGLContext *opengl) |
|
static void | opengl_compute_display_area (AVFormatContext *s) |
|
static av_cold void | opengl_get_texture_size (OpenGLContext *opengl, int in_width, int in_height, int *out_width, int *out_height) |
|
static av_cold void | opengl_fill_color_map (OpenGLContext *opengl) |
|
static av_cold GLuint | opengl_load_shader (OpenGLContext *opengl, GLenum type, const char *source) |
|
static av_cold int | opengl_compile_shaders (OpenGLContext *opengl, enum AVPixelFormat pix_fmt) |
|
static av_cold int | opengl_configure_texture (OpenGLContext *opengl, GLuint texture, GLsizei width, GLsizei height) |
|
static int | opengl_prepare (OpenGLContext *opengl) |
|
static int | opengl_create_window (AVFormatContext *h) |
|
static int | opengl_release_window (AVFormatContext *h) |
|
static av_cold int | opengl_write_trailer (AVFormatContext *h) |
|
static av_cold int | opengl_write_header (AVFormatContext *h) |
|
static uint8_t * | opengl_get_plane_pointer (OpenGLContext *opengl, AVPacket *pkt, int comp_index, const AVPixFmtDescriptor *desc) |
|
static int | opengl_write_packet (AVFormatContext *h, AVPacket *pkt) |
|
static int | opengl_write_frame (AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags) |
|
◆ APIENTRY
◆ FF_GL_RED_COMPONENT
#define FF_GL_RED_COMPONENT 0x1903; |
◆ FF_GL_UNSIGNED_BYTE_3_3_2
#define FF_GL_UNSIGNED_BYTE_3_3_2 0x8032 |
◆ FF_GL_UNSIGNED_BYTE_2_3_3_REV
#define FF_GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 |
◆ FF_GL_UNSIGNED_SHORT_1_5_5_5_REV
#define FF_GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 |
◆ FF_GL_UNPACK_ROW_LENGTH
#define FF_GL_UNPACK_ROW_LENGTH 0x0CF2 |
◆ FF_GL_ARRAY_BUFFER
#define FF_GL_ARRAY_BUFFER 0x8892 |
◆ FF_GL_ELEMENT_ARRAY_BUFFER
#define FF_GL_ELEMENT_ARRAY_BUFFER 0x8893 |
◆ FF_GL_STATIC_DRAW
#define FF_GL_STATIC_DRAW 0x88E4 |
◆ FF_GL_FRAGMENT_SHADER
#define FF_GL_FRAGMENT_SHADER 0x8B30 |
◆ FF_GL_VERTEX_SHADER
#define FF_GL_VERTEX_SHADER 0x8B31 |
◆ FF_GL_COMPILE_STATUS
#define FF_GL_COMPILE_STATUS 0x8B81 |
◆ FF_GL_LINK_STATUS
#define FF_GL_LINK_STATUS 0x8B82 |
◆ FF_GL_INFO_LOG_LENGTH
#define FF_GL_INFO_LOG_LENGTH 0x8B84 |
◆ OPENGL_ERROR_CHECK
#define OPENGL_ERROR_CHECK |
( |
|
ctx | ) |
|
Value:{\
GLenum err_code; \
if ((err_code = glGetError()) != GL_NO_ERROR) { \
av_log(
ctx,
AV_LOG_ERROR,
"OpenGL error occurred in '%s', line %d: %d\n", __func__, __LINE__, err_code); \
} \
}\
Definition at line 152 of file opengl_enc.c.
◆ LOAD_OPENGL_FUN
Value: procs->name = (
type)SelectedGetProcAddress(#
name); \
if (!procs->name) { \
}
◆ FILL_COMPONENT
#define FILL_COMPONENT |
( |
|
i | ) |
|
Value: { \
shift = (
desc->comp[
i].depth - 1) >> 3; \
opengl->color_map[(
i << 2) + (
desc->comp[
i].offset >>
shift)] = 1.0; \
}
◆ LOAD_TEXTURE_DATA
#define LOAD_TEXTURE_DATA |
( |
|
comp_index, |
|
|
|
sub |
|
) |
| |
◆ OFFSET
◆ ENC
◆ FF_PFNGLACTIVETEXTUREPROC
typedef void(APIENTRY * FF_PFNGLACTIVETEXTUREPROC) (GLenum texture) |
◆ FF_PFNGLGENBUFFERSPROC
typedef void(APIENTRY * FF_PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers) |
◆ FF_PFNGLDELETEBUFFERSPROC
typedef void(APIENTRY * FF_PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers) |
◆ FF_PFNGLBUFFERDATAPROC
typedef void(APIENTRY * FF_PFNGLBUFFERDATAPROC) (GLenum target, ptrdiff_t size, const GLvoid *data, GLenum usage) |
◆ FF_PFNGLBINDBUFFERPROC
typedef void(APIENTRY * FF_PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer) |
◆ FF_PFNGLGETATTRIBLOCATIONPROC
◆ FF_PFNGLENABLEVERTEXATTRIBARRAYPROC
typedef void(APIENTRY * FF_PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index) |
◆ FF_PFNGLVERTEXATTRIBPOINTERPROC
typedef void(APIENTRY * FF_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, uintptr_t pointer) |
◆ FF_PFNGLGETUNIFORMLOCATIONPROC
◆ FF_PFNGLUNIFORM1FPROC
typedef void(APIENTRY * FF_PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0) |
◆ FF_PFNGLUNIFORM1IPROC
typedef void(APIENTRY * FF_PFNGLUNIFORM1IPROC) (GLint location, GLint v0) |
◆ FF_PFNGLUNIFORMMATRIX4FVPROC
typedef void(APIENTRY * FF_PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
◆ FF_PFNGLCREATEPROGRAMPROC
typedef GLuint(APIENTRY * FF_PFNGLCREATEPROGRAMPROC) (void) |
◆ FF_PFNGLDELETEPROGRAMPROC
◆ FF_PFNGLUSEPROGRAMPROC
◆ FF_PFNGLLINKPROGRAMPROC
◆ FF_PFNGLGETPROGRAMIVPROC
typedef void(APIENTRY * FF_PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params) |
◆ FF_PFNGLGETPROGRAMINFOLOGPROC
typedef void(APIENTRY * FF_PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, char *infoLog) |
◆ FF_PFNGLATTACHSHADERPROC
typedef void(APIENTRY * FF_PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader) |
◆ FF_PFNGLCREATESHADERPROC
typedef GLuint(APIENTRY * FF_PFNGLCREATESHADERPROC) (GLenum type) |
◆ FF_PFNGLDELETESHADERPROC
typedef void(APIENTRY * FF_PFNGLDELETESHADERPROC) (GLuint shader) |
◆ FF_PFNGLCOMPILESHADERPROC
typedef void(APIENTRY * FF_PFNGLCOMPILESHADERPROC) (GLuint shader) |
◆ FF_PFNGLSHADERSOURCEPROC
typedef void(APIENTRY * FF_PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const char **string, const GLint *length) |
◆ FF_PFNGLGETSHADERIVPROC
typedef void(APIENTRY * FF_PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params) |
◆ FF_PFNGLGETSHADERINFOLOGPROC
typedef void(APIENTRY * FF_PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog) |
◆ opengl_prepare_vertex()
◆ opengl_draw()
static int opengl_draw |
( |
AVFormatContext * |
h, |
|
|
void * |
intput, |
|
|
int |
repaint, |
|
|
int |
is_pkt |
|
) |
| |
|
static |
◆ opengl_init_context()
◆ opengl_deinit_context()
◆ opengl_resize()
◆ opengl_control_message()
static int opengl_control_message |
( |
AVFormatContext * |
h, |
|
|
int |
type, |
|
|
void * |
data, |
|
|
size_t |
data_size |
|
) |
| |
|
static |
◆ opengl_load_procedures()
◆ opengl_make_identity()
static void opengl_make_identity |
( |
float |
matrix[16] | ) |
|
|
static |
◆ opengl_make_ortho()
◆ opengl_read_limits()
◆ opengl_get_fragment_shader_code()
static const char* opengl_get_fragment_shader_code |
( |
enum AVPixelFormat |
format | ) |
|
|
static |
◆ opengl_type_size()
static int opengl_type_size |
( |
GLenum |
type | ) |
|
|
static |
◆ opengl_get_texture_params()
◆ opengl_compute_display_area()
◆ opengl_get_texture_size()
static av_cold void opengl_get_texture_size |
( |
OpenGLContext * |
opengl, |
|
|
int |
in_width, |
|
|
int |
in_height, |
|
|
int * |
out_width, |
|
|
int * |
out_height |
|
) |
| |
|
static |
◆ opengl_fill_color_map()
◆ opengl_load_shader()
static av_cold GLuint opengl_load_shader |
( |
OpenGLContext * |
opengl, |
|
|
GLenum |
type, |
|
|
const char * |
source |
|
) |
| |
|
static |
◆ opengl_compile_shaders()
◆ opengl_configure_texture()
static av_cold int opengl_configure_texture |
( |
OpenGLContext * |
opengl, |
|
|
GLuint |
texture, |
|
|
GLsizei |
width, |
|
|
GLsizei |
height |
|
) |
| |
|
static |
◆ opengl_prepare()
◆ opengl_create_window()
◆ opengl_release_window()
◆ opengl_write_trailer()
◆ opengl_write_header()
◆ opengl_get_plane_pointer()
◆ opengl_write_packet()
◆ opengl_write_frame()
◆ g_index
const GLushort g_index[6] |
|
static |
◆ opengl_format_desc
◆ options
◆ opengl_class
Initial value:= {
.class_name = "opengl outdev",
}
Definition at line 1304 of file opengl_enc.c.
◆ ff_opengl_muxer
Initial value:= {
.p.name = "opengl",
}
Definition at line 1312 of file opengl_enc.c.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
static const AVOption options[]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int opengl_control_message(AVFormatContext *h, int type, void *data, size_t data_size)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static int opengl_write_frame(AVFormatContext *h, int stream_index, AVFrame **frame, unsigned flags)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int opengl_write_packet(AVFormatContext *h, AVPacket *pkt)
@ AV_CODEC_ID_WRAPPED_AVFRAME
Passthrough codec, AVFrames wrapped in AVPacket.
static const char * window_title
#define LIBAVUTIL_VERSION_INT
static int write_trailer(AVFormatContext *s1)
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int shift(int a, int b)
#define i(width, name, range_min, range_max)
static const AVClass opengl_class
static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
@ AV_OPT_TYPE_INT
Underlying C type is int.
static av_cold int opengl_write_trailer(AVFormatContext *h)
static av_cold int opengl_write_header(AVFormatContext *h)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
static void write_header(FFV1Context *f)