Add uniform Yangmi framing candidate for code37
This commit is contained in:
@@ -22,7 +22,7 @@ static void texture(GLuint id,int w,int h,const char *path) {
|
||||
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,data);free(data);
|
||||
}
|
||||
int main(int argc,char **v) {
|
||||
assert(argc==16);
|
||||
assert(argc==16 || argc==18);
|
||||
int bw=atoi(v[14]),bh=atoi(v[15]);assert(bw>0&&bh>0);
|
||||
int pw=atoi(v[6]),ph=atoi(v[7]),w=atoi(v[11]),h=atoi(v[12]);float x=atof(v[8]),y=atof(v[9]),opacity=atof(v[10]);
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC platform=(void*)eglGetProcAddress("eglGetPlatformDisplayEXT");assert(platform);
|
||||
@@ -38,7 +38,9 @@ int main(int argc,char **v) {
|
||||
GLuint ids[2];glGenTextures(2,ids);glActiveTexture(GL_TEXTURE0);texture(ids[0],bw,bh,v[3]);glUniform1i(glGetUniformLocation(p,"uBody"),0);
|
||||
glActiveTexture(GL_TEXTURE1);texture(ids[1],pw,ph,v[4]);glUniform1i(glGetUniformLocation(p,"uPatch"),1);
|
||||
glUniform2f(glGetUniformLocation(p,"uBodySize"),bw,bh);
|
||||
float scale=fminf((float)w/bw,(float)h/bh),mw=bw*scale,mh=bh*scale,left=(w-mw)/2,top=(h-mh)/2;
|
||||
float zoom=argc==18?atof(v[16]):1,centerY=argc==18?atof(v[17]):.5f;
|
||||
assert(isfinite(zoom)&&zoom>=1&&zoom<=2&&isfinite(centerY)&¢erY>=.4f&¢erY<=.6f);
|
||||
float scale=fminf((float)w/bw,(float)h/bh)*zoom,mw=bw*scale,mh=bh*scale,left=(w-mw)/2,top=h/2.f-mh*centerY;
|
||||
GLfloat pos[]={left/w*2-1,1-(top+mh)/h*2,(left+mw)/w*2-1,1-(top+mh)/h*2,left/w*2-1,1-top/h*2,(left+mw)/w*2-1,1-top/h*2};
|
||||
GLfloat uv[]={0,0,1,0,0,1,1,1};
|
||||
GLint a=glGetAttribLocation(p,"aPosition"),b=glGetAttribLocation(p,"aUv");glVertexAttribPointer(a,2,GL_FLOAT,GL_FALSE,0,pos);glEnableVertexAttribArray(a);glVertexAttribPointer(b,2,GL_FLOAT,GL_FALSE,0,uv);glEnableVertexAttribArray(b);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
package com.gorios.lanvoice
|
||||
object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=false;const val STARTUP_POSTER_RES_ID=1 }
|
||||
object BuildConfig { const val AVATAR_USER_ASSET_CANDIDATE=false;const val STARTUP_POSTER_RES_ID=1;const val AVATAR_FRAME_ZOOM=1f;const val AVATAR_FRAME_CENTER_Y=0.5f }
|
||||
|
||||
@@ -117,6 +117,20 @@ fun dynamicBodyCheck() {
|
||||
rejected(legacy+("body" to (legacy["body"] as Map<String,Any?>)+mapOf("width" to 720,"height" to 1280)))
|
||||
val fit=bodyFit(360,800,720,1280)
|
||||
check(fit.left==0f && fit.top==80f && fit.width==360f && fit.height==640f)
|
||||
for((w,h) in listOf(720 to 1280,360 to 800,800 to 480)) {
|
||||
val original=bodyFit(w,h,720,1280)
|
||||
val zoomed=bodyFit(w,h,720,1280,1.45f,.489f)
|
||||
fun near(a: Float,b: Float)=kotlin.math.abs(a-b)<.001f
|
||||
check(near(zoomed.width,original.width*1.45f) && near(zoomed.height,original.height*1.45f))
|
||||
check(near(zoomed.left+zoomed.width/2,w/2f) && near(zoomed.top+zoomed.height*.489f,h/2f))
|
||||
// The exact same source coordinates map body pixels and mouth rects.
|
||||
val patch=pack.patches[0]
|
||||
val displayX=zoomed.left+(patch.x+patch.width/2f)*zoomed.width/720
|
||||
val sourceX=(displayX-zoomed.left)*720/zoomed.width
|
||||
check(near(sourceX,patch.x+patch.width/2f))
|
||||
}
|
||||
for(zoom in listOf(Float.NaN,Float.POSITIVE_INFINITY,.9f,2.1f))check(runCatching { bodyFit(720,1280,720,1280,zoom) }.isFailure)
|
||||
for(center in listOf(Float.NaN,.39f,.61f))check(runCatching { bodyFit(720,1280,720,1280,1.45f,center) }.isFailure)
|
||||
fun render(codecW: Int,codecH: Int): Pair<List<ComposedBodyFrame>,List<String>> {
|
||||
TestScheduler.reset();CodecFixture.reset();GLFixture.reset()
|
||||
CodecFixture.width=codecW;CodecFixture.height=codecH;CodecFixture.frames=97;CodecFixture.fps=24
|
||||
|
||||
@@ -8,9 +8,11 @@ open class FrameLayout(val context: Context) {
|
||||
fun addView(view: Any, params: LayoutParams) { children.add(view) }
|
||||
open fun onDetachedFromWindow() {}
|
||||
}
|
||||
class ImageView(context: Context) {
|
||||
open class ImageView(context: Context) {
|
||||
enum class ScaleType { FIT_CENTER }
|
||||
var scaleType = ScaleType.FIT_CENTER; var alpha = 1f
|
||||
var scaleX=1f;var scaleY=1f;var translationY=0f
|
||||
open fun onSizeChanged(w: Int,h: Int,oldw: Int,oldh: Int) {}
|
||||
fun setImageResource(id: Int) {}
|
||||
fun setImageBitmap(bitmap: Any?) {}
|
||||
fun setImageDrawable(drawable: Any?) {}
|
||||
|
||||
Reference in New Issue
Block a user