Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (5)
  • Alexandre Janniaux's avatar
    misc: es_format: set orientation during setup · fbc22398
    Alexandre Janniaux authored and Steve Lhomme's avatar Steve Lhomme committed
    During video_format_Setup(), the size, visible size and source aspect
    ratio is defined for the given video_format_t instance, but those values
    only make sense for a given orientation. Transforming the picture would
    mean transform the coordinates, as seen in video_format_TransformBy().
    
    To ensure the correct behaviour is found when transforming after the
    setup, initialize the orientation to ORIENT_NORMAL as well.
    fbc22398
  • Alexandre Janniaux's avatar
    opengl: sampler: workaround libplacebo state change · a1a676bc
    Alexandre Janniaux authored and Steve Lhomme's avatar Steve Lhomme committed
    Libplacebo changes the current framebuffer when starting the pl_gpu
    opengl instance, leading to invalid framebuffer operation when it's
    being used for rendering afterwards.
    a1a676bc
  • Alexandre Janniaux's avatar
    test: opengl: add test for filters · 8ae846de
    Alexandre Janniaux authored and Steve Lhomme's avatar Steve Lhomme committed
    This test is able to use any offscreen opengl implementation available
    to run the opengl filters engine on both GL Core and GL ES, and will
    skip the test for one of those targets if no implementations are
    available.
    
    It currently mainly smoke-test the filters engine, while checking that
    orientation handling is correct, and uses glReadPixels to check the
    resulting rendered picture in a multi-platform way.
    8ae846de
  • Alexandre Janniaux's avatar
    opengl: renderer: add support for flipping · 824172ec
    Alexandre Janniaux authored and Steve Lhomme's avatar Steve Lhomme committed
    The current code is now able to rotate depending on the filters engine
    orientation coming from the OpenGL provider, but it wasn't able to flip
    yet. Because the orientation will rotate vertical flipping, only
    horizontal flipping is needed for any direction flipping.
    
    This commit adds support for those.
    824172ec
  • Alexandre Janniaux's avatar
    opengl: test mirrored orientation · 5e737ea4
    Alexandre Janniaux authored and Steve Lhomme's avatar Steve Lhomme committed
    Test the different missing orientation:
    
     - ORIENT_TRANSPOSED is ORIENT_ROTATED_270 + HFLIP
     - ORIENT_ANTITRANSPOSED is ORIENT_ROTATED_90 + HFLIP
     - ORIENT_HFLIP is ORIENT_NORMAL + HFLIP
     - ORIENT_VFLIP is ORIENT_ROTATED_180 + HFLIP
    5e737ea4
......@@ -10,6 +10,7 @@
* Adrien Maglo <magsoft at videolan dot org>
* Felix Paul Kühne <fkuehne at videolan dot org>
* Pierre d'Herbemont <pdherbemont at videolan dot org>
* Alexandre Janniaux <ajanni@videolabs.io>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
......@@ -593,8 +594,9 @@ error:
return VLC_ENOMEM;
}
static int BuildRectangle(GLfloat **vertexCoord, GLfloat **textureCoord, unsigned *nbVertices,
GLushort **indices, unsigned *nbIndices)
static int BuildRectangle(
GLfloat **vertexCoord, GLfloat **textureCoord, unsigned *nbVertices,
GLushort **indices, unsigned *nbIndices, video_orientation_t orientation)
{
*nbVertices = 4;
*nbIndices = 6;
......@@ -625,13 +627,30 @@ static int BuildRectangle(GLfloat **vertexCoord, GLfloat **textureCoord, unsigne
memcpy(*vertexCoord, coord, *nbVertices * 3 * sizeof(GLfloat));
static const GLfloat tex[] = {
static const GLfloat tex_normal[] = {
0.0, 1.0,
0.0, 0.0,
1.0, 1.0,
1.0, 0.0,
};
static const GLfloat tex_hflip[] = {
1.0, 1.0,
1.0, 0.0,
0.0, 1.0,
0.0, 0.0,
};
/* Since there is a bijection between symmetry and rotation,
* applying the general orientation in each case is equivalent
* to choosing the rotation we want to apply to the frame, and
* then decide whether we apply a horizontal flip or not. */
const GLfloat *tex;
if (ORIENT_IS_MIRROR(orientation))
tex = tex_hflip;
else
tex = tex_normal;
memcpy(*textureCoord, tex, *nbVertices * 2 * sizeof(GLfloat));
const GLushort ind[] = {
......@@ -645,7 +664,8 @@ static int BuildRectangle(GLfloat **vertexCoord, GLfloat **textureCoord, unsigne
}
static int SetupCoords(struct vlc_gl_renderer *renderer,
const struct vlc_gl_picture *pic)
const struct vlc_gl_picture *pic,
video_orientation_t orientation)
{
const opengl_vtable_t *vt = renderer->vt;
struct vlc_gl_sampler *sampler = renderer->sampler;
......@@ -660,7 +680,7 @@ static int SetupCoords(struct vlc_gl_renderer *renderer,
{
case PROJECTION_MODE_RECTANGULAR:
i_ret = BuildRectangle(&vertexCoord, &textureCoord, &nbVertices,
&indices, &nbIndices);
&indices, &nbIndices, orientation);
break;
case PROJECTION_MODE_EQUIRECTANGULAR:
i_ret = BuildSphere(&vertexCoord, &textureCoord, &nbVertices,
......@@ -728,7 +748,7 @@ Draw(struct vlc_gl_filter *filter, const struct vlc_gl_picture *pic,
if (!renderer->valid_coords)
{
int ret = SetupCoords(renderer, pic);
int ret = SetupCoords(renderer, pic, meta->orientation);
if (ret != VLC_SUCCESS)
return ret;
......
......@@ -982,6 +982,14 @@ vlc_gl_sampler_New(struct vlc_gl_t *gl, const struct vlc_gl_api *api,
.proc_ctx = gl,
#endif
};
const opengl_vtable_t *vt = priv->vt;
/* Workaround libplacebo changing the current framebuffer when running
* with OpenGL. */
GLint out_fb;
vt->GetIntegerv(GL_FRAMEBUFFER_BINDING, &out_fb);
priv->pl_opengl = pl_opengl_create(priv->pl_log, &gl_params);
if (!priv->pl_opengl)
{
......@@ -989,6 +997,8 @@ vlc_gl_sampler_New(struct vlc_gl_t *gl, const struct vlc_gl_api *api,
return NULL;
}
vt->BindFramebuffer(GL_FRAMEBUFFER, out_fb);
priv->pl_sh = pl_shader_alloc(priv->pl_log, &(struct pl_shader_params) {
.gpu = priv->pl_opengl->gpu,
.glsl = {
......
......@@ -82,6 +82,7 @@ void video_format_Setup( video_format_t *p_fmt, vlc_fourcc_t i_chroma,
p_fmt->i_visible_height = i_visible_height;
p_fmt->i_x_offset =
p_fmt->i_y_offset = 0;
p_fmt->orientation = ORIENT_NORMAL;
vlc_ureduce( &p_fmt->i_sar_num, &p_fmt->i_sar_den,
i_sar_num, i_sar_den, 0 );
......
......@@ -56,6 +56,14 @@ check_PROGRAMS = \
test_modules_stream_out_transcode \
$(NULL)
if HAVE_GL
check_PROGRAMS += test_modules_video_output_opengl_filters
endif
if HAVE_GLES2
check_PROGRAMS += test_modules_video_output_opengl_es2_filters
endif
if HAVE_DARWIN
check_PROGRAMS += test_src_misc_image_cvpx
endif
......@@ -190,6 +198,23 @@ test_modules_codec_hxxx_helper_SOURCES = modules/codec/hxxx_helper.c \
../modules/packetizer/h264_nal.c \
../modules/packetizer/hevc_nal.c
test_modules_codec_hxxx_helper_LDADD = $(LIBVLCCORE) $(LIBVLC)
test_modules_video_output_opengl_filters_SOURCES = \
modules/video_output/opengl/filters.c \
../modules/video_output/opengl/filters.c \
../modules/video_output/opengl/filters.h \
../modules/video_output/opengl/filter.c \
../modules/video_output/opengl/gl_api.c \
../modules/video_output/opengl/gl_api.h \
../modules/video_output/opengl/interop.c \
../modules/video_output/opengl/interop.h \
../modules/video_output/opengl/importer.c \
../modules/video_output/opengl/importer.h
test_modules_video_output_opengl_filters_LDADD = $(LIBVLCCORE) $(LIBVLC)
test_modules_video_output_opengl_filters_CPPFLAGS = $(AM_CPPFLAGS) -DVLC_TEST_OPENGL_API=VLC_OPENGL
test_modules_video_output_opengl_es2_filters_SOURCES = $(test_modules_video_output_opengl_filters_SOURCES)
test_modules_video_output_opengl_es2_filters_LDADD = $(LIBVLCCORE) $(LIBVLC)
test_modules_video_output_opengl_es2_filters_CPPFLAGS = $(AM_CPPFLAGS) -DVLC_TEST_OPENGL_API=VLC_OPENGL_ES2
test_src_video_output_SOURCES = \
src/video_output/video_output.c \
......
/*****************************************************************************
* opengl.c: test for the OpenGL client code
*****************************************************************************
* Copyright (C) 2023 VideoLabs
*
* Authors: Alexandre Janniaux <ajanni@videolabs.io>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifndef VLC_TEST_OPENGL_API
# error "Define VLC_TEST_OPENGL_API to the VLC_OPENGL API to use"
#endif
/* Define a builtin module for mocked parts */
#define MODULE_NAME test_opengl
#undef VLC_DYNAMIC_PLUGIN
#include "../../../libvlc/test.h"
#include "../../../lib/libvlc_internal.h"
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_opengl.h>
#include <vlc_filter.h>
#include <vlc_modules.h>
#include <vlc_vout_display.h>
#include "../../../modules/video_output/opengl/filters.h"
#include "../../../modules/video_output/opengl/gl_api.h"
static_assert(
VLC_TEST_OPENGL_API == VLC_OPENGL ||
VLC_TEST_OPENGL_API == VLC_OPENGL_ES2);
const char vlc_module_name[] = MODULE_STRING;
static const uint8_t green[] = { 0x0, 0xff, 0x00, 0xff };
static const uint8_t red[] = { 0xff, 0x0, 0x0, 0xff };
static const uint8_t blue[] = { 0x00, 0x0, 0xff, 0xff };
struct test_point
{
int x, y;
const uint8_t *color;
};
static void test_opengl_offscreen(
vlc_object_t *root,
video_orientation_t orientation,
struct test_point *points,
size_t points_count
){
struct vlc_decoder_device *device =
vlc_decoder_device_Create(root, NULL);
vlc_gl_t *gl = vlc_gl_CreateOffscreen(
root, device, 3, 3, VLC_TEST_OPENGL_API, NULL, NULL);
assert(gl != NULL);
if (device != NULL)
vlc_decoder_device_Release(device);
int ret = vlc_gl_MakeCurrent(gl);
assert(ret == VLC_SUCCESS);
struct vlc_gl_api api;
ret = vlc_gl_api_Init(&api, gl);
assert(ret == VLC_SUCCESS);
GLuint out_tex;
api.vt.GenTextures(1, &out_tex);
api.vt.BindTexture(GL_TEXTURE_2D, out_tex);
api.vt.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
api.vt.BindTexture(GL_TEXTURE_2D, 0);
GLuint out_fb;
api.vt.GenFramebuffers(1, &out_fb);
api.vt.BindFramebuffer(GL_FRAMEBUFFER, out_fb);
api.vt.BindFramebuffer(GL_READ_FRAMEBUFFER, out_fb);
api.vt.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, out_tex, 0);
assert(api.vt.CheckFramebufferStatus(GL_FRAMEBUFFER)
== GL_FRAMEBUFFER_COMPLETE);
GL_ASSERT_NOERROR(&api.vt);
video_format_t fmt;
video_format_Setup(&fmt, VLC_CODEC_RGBA, 3, 3, 3, 3, 1, 1);
fmt.primaries = COLOR_PRIMARIES_SRGB;
fmt.space = COLOR_SPACE_SRGB;
fmt.transfer = TRANSFER_FUNC_SRGB;
fmt.projection_mode = PROJECTION_MODE_RECTANGULAR;
struct vlc_gl_interop *interop =
vlc_gl_interop_New(gl, NULL, &fmt);
assert(interop != NULL);
GL_ASSERT_NOERROR(&api.vt);
GLint fbo_binding;
api.vt.GetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo_binding);
assert((GLuint)fbo_binding == out_fb);
assert(api.vt.CheckFramebufferStatus(GL_FRAMEBUFFER)
== GL_FRAMEBUFFER_COMPLETE);
struct vlc_gl_filters *filters =
vlc_gl_filters_New(gl, &api, interop, orientation);
assert(filters != NULL);
GL_ASSERT_NOERROR(&api.vt);
api.vt.GetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo_binding);
assert((GLuint)fbo_binding == out_fb);
assert(api.vt.CheckFramebufferStatus(GL_FRAMEBUFFER)
== GL_FRAMEBUFFER_COMPLETE);
struct vlc_gl_filter *filter =
vlc_gl_filters_Append(filters, "renderer", NULL);
assert(filter != NULL);
GL_ASSERT_NOERROR(&api.vt);
assert((GLuint)fbo_binding == out_fb);
assert(api.vt.CheckFramebufferStatus(GL_FRAMEBUFFER)
== GL_FRAMEBUFFER_COMPLETE);
(void)filter;
api.vt.GetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo_binding);
assert((GLuint)fbo_binding == out_fb);
assert(api.vt.CheckFramebufferStatus(GL_FRAMEBUFFER)
== GL_FRAMEBUFFER_COMPLETE);
ret = vlc_gl_filters_InitFramebuffers(filters);
assert(ret == VLC_SUCCESS);
GL_ASSERT_NOERROR(&api.vt);
api.vt.GetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo_binding);
assert((GLuint)fbo_binding == out_fb);
assert(api.vt.CheckFramebufferStatus(GL_FRAMEBUFFER)
== GL_FRAMEBUFFER_COMPLETE);
vlc_gl_filters_SetViewport(filters, 0, 0, 3, 3);
GL_ASSERT_NOERROR(&api.vt);
vlc_gl_filters_SetOutputSize(filters, 3, 3);
GL_ASSERT_NOERROR(&api.vt);
picture_t *picture = picture_NewFromFormat(&fmt);
assert(picture != NULL);
size_t size = picture->p[0].i_lines * picture->p[0].i_pitch / picture->p[0].i_pixel_pitch;
for (size_t i=0; i < size; ++i)
memcpy(&picture->p[0].p_pixels[i * 4], green, sizeof(green));
memcpy(&picture->p[0].p_pixels[0 * 4], red, sizeof(red));
memcpy(&picture->p[0].p_pixels[2 * 4], blue, sizeof(blue));
ret = vlc_gl_filters_UpdatePicture(filters, picture);
assert(ret == VLC_SUCCESS);
GL_ASSERT_NOERROR(&api.vt);
api.vt.GetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo_binding);
assert((GLuint)fbo_binding == out_fb);
ret = vlc_gl_filters_Draw(filters);
assert(ret == VLC_SUCCESS);
GL_ASSERT_NOERROR(&api.vt);
api.vt.GetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo_binding);
assert((GLuint)fbo_binding == out_fb);
api.vt.Finish();
GL_ASSERT_NOERROR(&api.vt);
/* Disable pixel packing to use glReadPixels. */
api.vt.BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
GL_ASSERT_NOERROR(&api.vt);
uint8_t pixel[4];
fprintf(stderr, "Results (vertically flipped):\n");
for (size_t i = 0; i < 3; ++i)
{
for (size_t j = 0; j < 3; ++j)
{
api.vt.ReadPixels(j, i, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
fprintf(stderr, " %u:%u:%u:%u", pixel[0], pixel[1], pixel[2], pixel[3]);
}
fprintf(stderr, "\n");
}
for (size_t i = 0; i < points_count; ++i)
{
api.vt.ReadPixels(points[i].x, points[i].y, 1, 1, GL_RGBA,
GL_UNSIGNED_BYTE, &pixel);
GL_ASSERT_NOERROR(&api.vt);
assert(memcmp(pixel, points[i].color, sizeof(pixel)) == 0);
}
vlc_gl_filters_Delete(filters);
GL_ASSERT_NOERROR(&api.vt);
vlc_gl_interop_Delete(interop);
GL_ASSERT_NOERROR(&api.vt);
vlc_gl_ReleaseCurrent(gl);
vlc_gl_Delete(gl);
}
int main( int argc, char **argv )
{
(void)argc; (void)argv;
test_init();
const char * const vlc_argv[] = {
"-vvv", "--aout=dummy", "--text-renderer=dummy",
};
libvlc_instance_t *vlc = libvlc_new(ARRAY_SIZE(vlc_argv), vlc_argv);
vlc_object_t *root = &vlc->p_libvlc_int->obj;
const char *cap =
(VLC_TEST_OPENGL_API == VLC_OPENGL) ? "opengl offscreen" :
(VLC_TEST_OPENGL_API == VLC_OPENGL_ES2) ? "opengl es2 offscreen" :
NULL;
assert(cap != NULL);
fprintf(stderr, "Looking for cap %s\n", cap);
module_t **providers;
size_t strict_matches;
ssize_t provider_available = vlc_module_match(
cap, NULL, false, &providers, &strict_matches);
(void)strict_matches;
free(providers);
if (provider_available <= 0)
{
libvlc_release(vlc);
return 77;
}
struct vlc_decoder_device *device =
vlc_decoder_device_Create(root, NULL);
vlc_gl_t *gl = vlc_gl_CreateOffscreen(
root, device, 3, 3, VLC_TEST_OPENGL_API, NULL, NULL);
if (device != NULL)
vlc_decoder_device_Release(device);
if (gl == NULL)
{
libvlc_release(vlc);
return 77;
}
vlc_gl_Delete(gl);
struct test_point points_normal[] = {
{ 1, 1, green },
{ 0, 2, red },
{ 2, 2, blue },
};
test_opengl_offscreen(root, ORIENT_NORMAL,
points_normal, ARRAY_SIZE(points_normal));
struct test_point points_rotated_90[] = {
{ 1, 1, green },
{ 0, 0, red },
{ 0, 2, blue },
};
test_opengl_offscreen(root, ORIENT_ROTATED_90,
points_rotated_90, ARRAY_SIZE(points_rotated_90));
struct test_point points_rotated_180[] = {
{ 1, 1, green },
{ 2, 0, red },
{ 0, 0, blue },
};
test_opengl_offscreen(root, ORIENT_ROTATED_180,
points_rotated_180, ARRAY_SIZE(points_rotated_180));
struct test_point points_rotated_270[] = {
{ 1, 1, green },
{ 2, 2, red },
{ 2, 0, blue },
};
test_opengl_offscreen(root, ORIENT_ROTATED_270,
points_rotated_270, ARRAY_SIZE(points_rotated_270));
struct test_point points_hflip[] = {
{ 1, 1, green },
{ 2, 2, red },
{ 0, 2, blue },
};
test_opengl_offscreen(root, ORIENT_HFLIPPED,
points_hflip, ARRAY_SIZE(points_hflip));
struct test_point points_vflip[] = {
{ 1, 1, green },
{ 0, 0, red },
{ 2, 0, blue },
};
test_opengl_offscreen(root, ORIENT_VFLIPPED,
points_vflip, ARRAY_SIZE(points_vflip));
struct test_point points_transposed[] = {
{ 1, 1, green },
{ 2, 0, red },
{ 2, 2, blue },
};
test_opengl_offscreen(root, ORIENT_TRANSPOSED,
points_transposed, ARRAY_SIZE(points_transposed));
struct test_point points_antitransposed[] = {
{ 1, 1, green },
{ 0, 2, red },
{ 0, 0, blue },
};
test_opengl_offscreen(root, ORIENT_ANTI_TRANSPOSED,
points_antitransposed, ARRAY_SIZE(points_antitransposed));
libvlc_release(vlc);
return 0;
}