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 (2)
  • Romain Vimont's avatar
    opengl: simplify TexSize multiplication · 893aa567
    Romain Vimont authored and Romain Vimont's avatar Romain Vimont committed
    Multiply two vec2 directly instead of multiplying their components
    separately.
    893aa567
  • Romain Vimont's avatar
    opengl: simplify TexCoordsMaps in sampler · 499b7ef7
    Romain Vimont authored and Romain Vimont's avatar Romain Vimont committed
    The input picture may contain padding, for two reasons:
     1. the rectangle defined by the picture_t offset and visible width and
        height may not cover the whole picture size;
     2. if the OpenGL API does not support NPOT textures, textures are
        created with power-of-two dimensions.
    
    As a consequence, for sampling, the coordinates (between 0 and 1 in both
    dimensions) must be transformed to take the padding into account.
    
    These transformations were computed and performed per-plane. Therefore,
    there were _n_ "TexCoordsMaps" matrices for a picture with _n_ planes.
    
    However, these transformations are necessarily the same for all planes:
     1. the picture_t offset/sizes are defined for the whole picture (then
        scaled appropriately for each plane);
     2. since the ratio between different planes of the same pictures is
        always a power of two (e.g. in YUV 4:2:0, the size of U and V planes
        are half the size of the Y plane in both dimensions), this property
        holds even if we align the dimensions of each plane texture to the
        next power-of-two.
    
    Therefore, use a single transformation matrix.
    499b7ef7
......@@ -48,7 +48,7 @@ struct vlc_gl_sampler_priv {
struct {
GLfloat OrientationMatrix[4*4];
GLfloat TexCoordsMaps[PICTURE_PLANE_MAX][3*3];
GLfloat TexCoordsMap[3*3];
} var;
struct {
GLint Textures[PICTURE_PLANE_MAX];
......@@ -58,7 +58,7 @@ struct vlc_gl_sampler_priv {
GLint TransformMatrix;
GLint OrientationMatrix;
GLint TexCoordsMaps[PICTURE_PLANE_MAX];
GLint TexCoordsMap;
} uloc;
bool yuv_color;
......@@ -296,19 +296,18 @@ sampler_base_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
vt->GetUniformLocation(program, "OrientationMatrix");
assert(priv->uloc.OrientationMatrix != -1);
priv->uloc.TexCoordsMap = vt->GetUniformLocation(program, "TexCoordsMap");
assert(priv->uloc.TexCoordsMap != -1);
assert(sampler->tex_count < 10); /* to guarantee variable names length */
for (unsigned int i = 0; i < sampler->tex_count; ++i)
{
char name[sizeof("TexCoordsMaps[X]")];
char name[sizeof("Textures[X]")];
snprintf(name, sizeof(name), "Textures[%1u]", i);
priv->uloc.Textures[i] = vt->GetUniformLocation(program, name);
assert(priv->uloc.Textures[i] != -1);
snprintf(name, sizeof(name), "TexCoordsMaps[%1u]", i);
priv->uloc.TexCoordsMaps[i] = vt->GetUniformLocation(program, name);
assert(priv->uloc.TexCoordsMaps[i] != -1);
if (priv->tex_target == GL_TEXTURE_RECTANGLE)
{
snprintf(name, sizeof(name), "TexSizes[%1u]", i);
......@@ -356,10 +355,11 @@ sampler_base_load(struct vlc_gl_sampler *sampler)
vt->ActiveTexture(GL_TEXTURE0 + i);
vt->BindTexture(priv->tex_target, priv->textures[i]);
vt->UniformMatrix3fv(priv->uloc.TexCoordsMaps[i], 1, GL_FALSE,
priv->var.TexCoordsMaps[i]);
}
vt->UniformMatrix3fv(priv->uloc.TexCoordsMap, 1, GL_FALSE,
priv->var.TexCoordsMap);
/* Return the expected transform matrix if interop == NULL */
const GLfloat *tm = GetTransformMatrix(priv->interop);
vt->UniformMatrix4fv(priv->uloc.TransformMatrix, 1, GL_FALSE, tm);
......@@ -425,9 +425,8 @@ sampler_xyz12_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
vt->GetUniformLocation(program, "OrientationMatrix");
assert(priv->uloc.OrientationMatrix != -1);
priv->uloc.TexCoordsMaps[0] =
vt->GetUniformLocation(program, "TexCoordsMaps[0]");
assert(priv->uloc.TexCoordsMaps[0] != -1);
priv->uloc.TexCoordsMap = vt->GetUniformLocation(program, "TexCoordsMap");
assert(priv->uloc.TexCoordsMap != -1);
}
static void
......@@ -442,8 +441,8 @@ sampler_xyz12_load(struct vlc_gl_sampler *sampler)
vt->ActiveTexture(GL_TEXTURE0);
vt->BindTexture(priv->tex_target, priv->textures[0]);
vt->UniformMatrix3fv(priv->uloc.TexCoordsMaps[0], 1, GL_FALSE,
priv->var.TexCoordsMaps[0]);
vt->UniformMatrix3fv(priv->uloc.TexCoordsMap, 1, GL_FALSE,
priv->var.TexCoordsMap);
/* Return the expected transform matrix if interop == NULL */
const GLfloat *tm = GetTransformMatrix(priv->interop);
......@@ -482,13 +481,11 @@ xyz12_shader_init(struct vlc_gl_sampler *sampler)
"uniform mat4 TransformMatrix;\n"
"uniform mat4 OrientationMatrix;\n"
"uniform mat3 TexCoordsMaps[1];\n"
"uniform mat3 TexCoordsMap;\n"
"vec4 vlc_texture(vec2 pic_coords)\n"
"{ "
" vec4 v_in, v_out;"
/* Homogeneous (oriented) coordinates */
" vec3 pic_hcoords = vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).st, 1.0);\n"
" vec2 tex_coords = (TexCoordsMaps[0] * pic_hcoords).st;\n"
" vec2 tex_coords = (TexCoordsMap * vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).xy, 1.0)).xy;\n"
" v_in = texture2D(Textures[0], tex_coords);\n"
" v_in = pow(v_in, xyz_gamma);"
" v_out = matrix_xyz_rgb * v_in ;"
......@@ -778,9 +775,8 @@ sampler_planes_fetch_locations(struct vlc_gl_sampler *sampler, GLuint program)
priv->uloc.Textures[0] = vt->GetUniformLocation(program, "Texture");
assert(priv->uloc.Textures[0] != -1);
priv->uloc.TexCoordsMaps[0] =
vt->GetUniformLocation(program, "TexCoordsMap");
assert(priv->uloc.TexCoordsMaps[0] != -1);
priv->uloc.TexCoordsMap = vt->GetUniformLocation(program, "TexCoordsMap");
assert(priv->uloc.TexCoordsMap != -1);
if (priv->tex_target == GL_TEXTURE_RECTANGLE)
{
......@@ -803,13 +799,8 @@ sampler_planes_load(struct vlc_gl_sampler *sampler)
vt->ActiveTexture(GL_TEXTURE0);
vt->BindTexture(priv->tex_target, priv->textures[plane]);
/* Only one TexCoordMap matrix is necessary in the shader (its location is
* stored in uloc.TexCoordsMaps[0]), as there is only one plane per
* execution. However, for a single picture, there are several coords
* mapping matrices (one per plane), so the correct one
* (var.TexCoordsMaps[plane]) must be bound. */
vt->UniformMatrix3fv(priv->uloc.TexCoordsMaps[0], 1, GL_FALSE,
priv->var.TexCoordsMaps[plane]);
vt->UniformMatrix3fv(priv->uloc.TexCoordsMap, 1, GL_FALSE,
priv->var.TexCoordsMap);
/* Return the expected transform matrix if interop == NULL */
const GLfloat *tm = GetTransformMatrix(priv->interop);
......@@ -851,15 +842,12 @@ sampler_planes_init(struct vlc_gl_sampler *sampler)
ADD("uniform vec2 TexSize;\n");
ADD("vec4 vlc_texture(vec2 pic_coords) {\n"
/* Homogeneous (oriented) coordinates */
" vec3 pic_hcoords = vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).st, 1.0);\n"
" vec2 tex_coords = (TexCoordsMap * pic_hcoords).st;\n");
" vec2 tex_coords = (TexCoordsMap * vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).xy, 1.0)).xy;\n");
if (tex_target == GL_TEXTURE_RECTANGLE)
{
/* The coordinates are in texels values, not normalized */
ADD(" tex_coords = vec2(tex_coords.x * TexSize.x,\n"
" tex_coords.y * TexSize.y);\n");
ADD(" tex_coords = TexSize * tex_coords;\n");
}
ADDF(" return %s(Texture, tex_coords);\n", texture_fn);
......@@ -944,7 +932,7 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
ADD("uniform mat4 TransformMatrix;\n"
"uniform mat4 OrientationMatrix;\n");
ADDF("uniform %s Textures[%u];\n", glsl_sampler, tex_count);
ADDF("uniform mat3 TexCoordsMaps[%u];\n", tex_count);
ADD("uniform mat3 TexCoordsMap;\n");
#ifdef HAVE_LIBPLACEBO
if (priv->pl_sh) {
......@@ -1034,9 +1022,7 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
ADD("uniform mat4 ConvMatrix;\n");
ADD("vec4 vlc_texture(vec2 pic_coords) {\n"
/* Homogeneous (oriented) coordinates */
" vec3 pic_hcoords = vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).st, 1.0);\n"
" vec2 tex_coords;\n");
" vec2 tex_coords = (TexCoordsMap * vec3((TransformMatrix * OrientationMatrix * vec4(pic_coords, 0.0, 1.0)).xy, 1.0)).xy;\n");
unsigned color_count;
if (is_yuv) {
......@@ -1048,14 +1034,15 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
const char *swizzle = swizzle_per_tex[i];
assert(swizzle);
size_t swizzle_count = strlen(swizzle);
ADDF(" tex_coords = (TexCoordsMaps[%u] * pic_hcoords).st;\n", i);
if (tex_target == GL_TEXTURE_RECTANGLE)
{
/* The coordinates are in texels values, not normalized */
ADDF(" tex_coords = vec2(tex_coords.x * TexSizes[%u].x,\n"
" tex_coords.y * TexSizes[%u].y);\n", i, i);
ADDF(" texel = %s(Textures[%u], TexSizes[%u] * tex_coords);\n", lookup, i, i);
}
else
{
ADDF(" texel = %s(Textures[%u], tex_coords);\n", lookup, i);
}
ADDF(" texel = %s(Textures[%u], tex_coords);\n", lookup, i);
for (unsigned j = 0; j < swizzle_count; ++j)
{
ADDF(" pixel[%u] = texel.%c;\n", color_idx, swizzle[j]);
......@@ -1068,7 +1055,6 @@ opengl_fragment_shader_init(struct vlc_gl_sampler *sampler, GLenum tex_target,
}
else
{
ADD(" tex_coords = (TexCoordsMaps[0] * pic_hcoords).st;\n");
if (tex_target == GL_TEXTURE_RECTANGLE)
ADD(" tex_coords *= TexSizes[0];\n");
......@@ -1178,12 +1164,9 @@ CreateSampler(struct vlc_gl_interop *interop, struct vlc_gl_t *gl,
unsigned tex_count = sampler->tex_count;
assert(!interop || interop->tex_count == tex_count);
for (unsigned i = 0; i < tex_count; ++i)
{
/* This might be updated in UpdatePicture for non-direct samplers */
memcpy(&priv->var.TexCoordsMaps[i], MATRIX3_IDENTITY,
sizeof(MATRIX3_IDENTITY));
}
/* This might be updated in UpdatePicture for non-direct samplers */
memcpy(&priv->var.TexCoordsMap, MATRIX3_IDENTITY,
sizeof(MATRIX3_IDENTITY));
if (interop)
{
......@@ -1275,74 +1258,74 @@ vlc_gl_sampler_UpdatePicture(struct vlc_gl_sampler *sampler, picture_t *picture)
|| source->i_visible_width != priv->last_source.i_visible_width
|| source->i_visible_height != priv->last_source.i_visible_height)
{
memset(priv->var.TexCoordsMaps, 0, sizeof(priv->var.TexCoordsMaps));
for (unsigned j = 0; j < interop->tex_count; j++)
{
float scale_w = (float)interop->texs[j].w.num / interop->texs[j].w.den
/ priv->tex_widths[j];
float scale_h = (float)interop->texs[j].h.num / interop->texs[j].h.den
/ priv->tex_heights[j];
/* Warning: if NPOT is not supported a larger texture is
allocated. This will cause right and bottom coordinates to
land on the edge of two texels with the texels to the
right/bottom uninitialized by the call to
glTexSubImage2D. This might cause a green line to appear on
the right/bottom of the display.
There are two possible solutions:
- Manually mirror the edges of the texture.
- Add a "-1" when computing right and bottom, however the
last row/column might not be displayed at all.
*/
float left = (source->i_x_offset + 0 ) * scale_w;
float top = (source->i_y_offset + 0 ) * scale_h;
float right = (source->i_x_offset + source->i_visible_width ) * scale_w;
float bottom = (source->i_y_offset + source->i_visible_height) * scale_h;
/**
* This matrix converts from picture coordinates (in range [0; 1])
* to textures coordinates where the picture is actually stored
* (removing paddings).
*
* texture (in texture coordinates)
* +----------------+--- 0.0
* | |
* | +---------+---|--- top
* | | picture | |
* | +---------+---|--- bottom
* | . . |
* | . . |
* +----------------+--- 1.0
* | . . |
* 0.0 left right 1.0 (in texture coordinates)
*
* In particular:
* - (0.0, 0.0) is mapped to (left, top)
* - (1.0, 1.0) is mapped to (right, bottom)
*
* This is an affine 2D transformation, so the input coordinates
* are given as a 3D vector in the form (x, y, 1), and the output
* is (x', y', 1).
*
* The paddings are l (left), r (right), t (top) and b (bottom).
*
* / (r-l) 0 l \
* matrix = | 0 (b-t) t |
* \ 0 0 1 /
*
* It is stored in column-major order.
*/
GLfloat *matrix = priv->var.TexCoordsMaps[j];
memset(priv->var.TexCoordsMap, 0, sizeof(priv->var.TexCoordsMap));
/* The transformation is the same for all planes, even with power-of-two
* textures. */
float scale_w = (float)interop->texs[0].w.num / interop->texs[0].w.den
/ priv->tex_widths[0];
float scale_h = (float)interop->texs[0].h.num / interop->texs[0].h.den
/ priv->tex_heights[0];
/* Warning: if NPOT is not supported a larger texture is
allocated. This will cause right and bottom coordinates to
land on the edge of two texels with the texels to the
right/bottom uninitialized by the call to
glTexSubImage2D. This might cause a green line to appear on
the right/bottom of the display.
There are two possible solutions:
- Manually mirror the edges of the texture.
- Add a "-1" when computing right and bottom, however the
last row/column might not be displayed at all.
*/
float left = (source->i_x_offset + 0 ) * scale_w;
float top = (source->i_y_offset + 0 ) * scale_h;
float right = (source->i_x_offset + source->i_visible_width ) * scale_w;
float bottom = (source->i_y_offset + source->i_visible_height) * scale_h;
/**
* This matrix converts from picture coordinates (in range [0; 1])
* to textures coordinates where the picture is actually stored
* (removing paddings).
*
* texture (in texture coordinates)
* +----------------+--- 0.0
* | |
* | +---------+---|--- top
* | | picture | |
* | +---------+---|--- bottom
* | . . |
* | . . |
* +----------------+--- 1.0
* | . . |
* 0.0 left right 1.0 (in texture coordinates)
*
* In particular:
* - (0.0, 0.0) is mapped to (left, top)
* - (1.0, 1.0) is mapped to (right, bottom)
*
* This is an affine 2D transformation, so the input coordinates
* are given as a 3D vector in the form (x, y, 1), and the output
* is (x', y', 1).
*
* The paddings are l (left), r (right), t (top) and b (bottom).
*
* / (r-l) 0 l \
* matrix = | 0 (b-t) t |
* \ 0 0 1 /
*
* It is stored in column-major order.
*/
GLfloat *matrix = priv->var.TexCoordsMap;
#define COL(x) (x*3)
#define ROW(x) (x)
matrix[COL(0) + ROW(0)] = right - left;
matrix[COL(1) + ROW(1)] = bottom - top;
matrix[COL(2) + ROW(0)] = left;
matrix[COL(2) + ROW(1)] = top;
matrix[COL(2) + ROW(2)] = 1;
matrix[COL(0) + ROW(0)] = right - left;
matrix[COL(1) + ROW(1)] = bottom - top;
matrix[COL(2) + ROW(0)] = left;
matrix[COL(2) + ROW(1)] = top;
matrix[COL(2) + ROW(2)] = 1;
#undef COL
#undef ROW
}
priv->last_source.i_x_offset = source->i_x_offset;
priv->last_source.i_y_offset = source->i_y_offset;
......