Rev 4762 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4762 | Rev 4998 | ||
---|---|---|---|
Line 293... | Line 293... | ||
293 | return 5; |
293 | return 5; |
294 | }
|
294 | }
|
295 | 295 | ||
296 | t[1] = getticks(); |
296 | t[1] = getticks(); |
297 | 297 | ||
298 | /*** 3 planes --> packed conversion ***/
|
- | |
299 | {
|
- | |
300 | uint8_t *const dstpic = codec->pic; |
298 | uint8_t *const dstpic = codec->pic; |
301 | 299 | ||
302 | const uint8_t *const yplane = img->planes[VPX_PLANE_Y]; |
300 | uint8_t const *const yplane = img->planes[VPX_PLANE_Y]; |
303 | const uint8_t *const uplane = img->planes[VPX_PLANE_U]; |
301 | uint8_t const *const uplane = img->planes[VPX_PLANE_U]; |
304 | const uint8_t *const vplane = img->planes[VPX_PLANE_V]; |
302 | uint8_t const *const vplane = img->planes[VPX_PLANE_V]; |
305 | 303 | ||
306 | int32_t ystride = img->stride[VPX_PLANE_Y]; |
304 | const int32_t ystride = img->stride[VPX_PLANE_Y]; |
307 | int32_t ustride = img->stride[VPX_PLANE_U]; |
305 | const int32_t ustride = img->stride[VPX_PLANE_U]; |
308 | int32_t vstride = img->stride[VPX_PLANE_V]; |
306 | const int32_t vstride = img->stride[VPX_PLANE_V]; |
309 | 307 | ||
- | 308 | if (glinfo.glsl) /*** 3 planes --> packed conversion ***/ |
|
- | 309 | {
|
|
310 | int32_t x, y; |
310 | int32_t x, y; |
311 | const int32_t width=img->d_w, height = img->d_h; |
311 | const int32_t width = img->d_w, height = img->d_h; |
312 | 312 | ||
313 | for (y=0; y<height; y+=2) |
313 | for (y = 0; y < height; y += 2) |
314 | {
|
314 | {
|
Line 332... | Line 332... | ||
332 | dstpic[((width*(y+1) + x)<<2) + 2] = v; |
332 | dstpic[((width * (y + 1) + x) << 2) + 2] = v; |
333 | dstpic[((width*(y+1) + x+1)<<2) + 2] = v; |
333 | dstpic[((width * (y + 1) + x + 1) << 2) + 2] = v; |
334 | }
|
334 | }
|
335 | }
|
335 | }
|
336 | }
|
336 | }
|
- | 337 | else /*** 3 planes --> packed conversion (RGB) ***/ |
|
- | 338 | {
|
|
- | 339 | int i = 0; |
|
- | 340 | ||
- | 341 | for (unsigned int imgY = 0; imgY < img->d_h; imgY++) |
|
- | 342 | {
|
|
- | 343 | for (unsigned int imgX = 0; imgX < img->d_w; imgX++) |
|
- | 344 | {
|
|
- | 345 | uint8_t const y = yplane[imgY * ystride + imgX]; |
|
- | 346 | uint8_t const u = uplane[(imgY >> 1) * ustride + (imgX >> 1)]; |
|
- | 347 | uint8_t const v = vplane[(imgY >> 1) * vstride + (imgX >> 1)]; |
|
- | 348 | ||
- | 349 | int const c = y - 16; |
|
- | 350 | int const d = (u + -128); |
|
- | 351 | int const e = (v + -128); |
|
- | 352 | int const c298 = c * 298; |
|
- | 353 | ||
- | 354 | dstpic[i + 0] = (uint8_t)clamp((c298 + 409 * e - -128) >> 8, 0, 255); |
|
- | 355 | dstpic[i + 1] = (uint8_t)clamp((c298 - 100 * d - 208 * e - -128) >> 8, 0, 255); |
|
- | 356 | dstpic[i + 2] = (uint8_t)clamp((c298 + 516 * d - -128) >> 8, 0, 255); |
|
- | 357 | ||
- | 358 | i += 3; |
|
- | 359 | }
|
|
- | 360 | }
|
|
- | 361 | }
|
|
337 | 362 | ||
338 | t[2] = getticks(); |
363 | t[2] = getticks(); |
339 | 364 | ||
340 | codec->sumtimes[0] += t[1]-t[0]; |
365 | codec->sumtimes[0] += t[1]-t[0]; |
341 | codec->sumtimes[1] += t[2]-t[1]; |
366 | codec->sumtimes[1] += t[2]-t[1]; |
Line 381... | Line 406... | ||
381 | " gl_FragColor = vec4(r,g,b,1.0);\n"
|
406 | " gl_FragColor = vec4(r,g,b,1.0);\n"
|
382 | "}\n"; |
407 | "}\n"; |
383 | 408 | ||
384 | void animvpx_setup_glstate(void) |
409 | void animvpx_setup_glstate(void) |
385 | {
|
410 | {
|
- | 411 | if (glinfo.glsl) |
|
- | 412 | {
|
|
386 | GLint gli;
|
413 | GLint gli;
|
387 | GLhandleARB FSHandle, PHandle; |
414 | GLhandleARB FSHandle, PHandle; |
388 | static char logbuf[512]; |
415 | static char logbuf[512]; |
389 | 416 | ||
390 | // first, compile the fragment shader
|
417 | // first, compile the fragment shader
|
Line 411... | Line 438... | ||
411 | if (logbuf[0]) |
438 | if (logbuf[0]) |
412 | OSD_Printf("animvpx link log: %s\n", logbuf); |
439 | OSD_Printf("animvpx link log: %s\n", logbuf); |
413 | 440 | ||
414 | /* Finally, use the program. */
|
441 | /* Finally, use the program. */
|
415 | bglUseProgramObjectARB(PHandle); |
442 | bglUseProgramObjectARB(PHandle); |
- | 443 | }
|
|
416 | 444 | ||
417 | ////////// GL STATE //////////
|
445 | ////////// GL STATE //////////
|
418 | 446 | ||
419 | //Force fullscreen (glox1=-1 forces it to restore afterwards)
|
447 | //Force fullscreen (glox1=-1 forces it to restore afterwards)
|
420 | bglViewport(0,0,xdim,ydim); glox1 = -1; |
448 | bglViewport(0,0,xdim,ydim); glox1 = -1; |
Line 423... | Line 451... | ||
423 | bglLoadIdentity(); |
451 | bglLoadIdentity(); |
424 | 452 | ||
425 | bglMatrixMode(GL_PROJECTION); |
453 | bglMatrixMode(GL_PROJECTION); |
426 | bglLoadIdentity(); |
454 | bglLoadIdentity(); |
427 | 455 | ||
428 | bglMatrixMode(GL_COLOR); |
- | |
429 | bglLoadIdentity(); |
- | |
430 | - | ||
431 | bglMatrixMode(GL_TEXTURE); |
456 | bglMatrixMode(GL_TEXTURE); |
432 | bglLoadIdentity(); |
457 | bglLoadIdentity(); |
433 | 458 | ||
434 | bglPushAttrib(GL_ENABLE_BIT); |
459 | // bglPushAttrib(GL_ENABLE_BIT);
|
435 | bglDisable(GL_ALPHA_TEST); |
460 | bglDisable(GL_ALPHA_TEST); |
436 | // bglDisable(GL_LIGHTING);
|
- | |
437 | bglDisable(GL_DEPTH_TEST); |
461 | bglDisable(GL_DEPTH_TEST); |
438 | bglDisable(GL_BLEND); |
462 | bglDisable(GL_BLEND); |
439 | bglDisable(GL_CULL_FACE); |
463 | bglDisable(GL_CULL_FACE); |
440 | // bglDisable(GL_SCISSOR_TEST);
|
- | |
441 | bglEnable(GL_TEXTURE_2D); |
464 | bglEnable(GL_TEXTURE_2D); |
442 | 465 | ||
443 | - | ||
444 | bglActiveTextureARB(GL_TEXTURE0_ARB); |
466 | bglActiveTextureARB(GL_TEXTURE0_ARB); |
445 | bglGenTextures(1, &texname); |
467 | bglGenTextures(1, &texname); |
446 | // gli = bglGetUniformLocationARB(PHandle,"tex");
|
- | |
447 | // bglUniform1iARB(gli,0); // 0: texture unit
|
- | |
448 | bglBindTexture(GL_TEXTURE_2D, texname); |
468 | bglBindTexture(GL_TEXTURE_2D, texname); |
449 | 469 | ||
450 | bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); |
470 | bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); |
451 | bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); |
471 | bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); |
452 | bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
472 | bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
Line 459... | Line 479... | ||
459 | bglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
479 | bglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
460 | }
|
480 | }
|
461 | 481 | ||
462 | void animvpx_restore_glstate(void) |
482 | void animvpx_restore_glstate(void) |
463 | {
|
483 | {
|
- | 484 | if (glinfo.glsl) |
|
464 | bglUseProgramObjectARB(0); |
485 | bglUseProgramObjectARB(0); |
465 | 486 | ||
466 | bglPopAttrib(); |
487 | // bglPopAttrib();
|
467 | 488 | ||
468 | bglDeleteTextures(1, &texname); |
489 | bglDeleteTextures(1, &texname); |
469 | texname = 0; |
490 | texname = 0; |
470 | texuploaded = 0; |
491 | texuploaded = 0; |
471 | }
|
492 | }
|
Line 478... | Line 499... | ||
478 | return 1; |
499 | return 1; |
479 | 500 | ||
480 | if (codec->pic == NULL) |
501 | if (codec->pic == NULL) |
481 | return 2; // shouldn't happen |
502 | return 2; // shouldn't happen |
482 | 503 | ||
- | 504 | int fmt = glinfo.glsl ? GL_RGBA : GL_RGB; |
|
- | 505 | ||
483 | if (!texuploaded) |
506 | if (!texuploaded) |
484 | {
|
507 | {
|
485 | bglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, codec->width,codec->height, |
508 | bglTexImage2D(GL_TEXTURE_2D, 0, fmt, codec->width,codec->height, |
486 | 0, GL_RGBA, GL_UNSIGNED_BYTE, codec->pic); |
509 | 0, fmt, GL_UNSIGNED_BYTE, codec->pic); |
487 | texuploaded = 1; |
510 | texuploaded = 1; |
488 | }
|
511 | }
|
489 | else
|
512 | else
|
490 | {
|
513 | {
|
491 | bglTexSubImage2D(GL_TEXTURE_2D, 0, 0,0, codec->width,codec->height, |
514 | bglTexSubImage2D(GL_TEXTURE_2D, 0, 0,0, codec->width,codec->height, |
492 | GL_RGBA, GL_UNSIGNED_BYTE, codec->pic); |
515 | fmt, GL_UNSIGNED_BYTE, codec->pic); |
493 | }
|
516 | }
|
494 | 517 | ||
495 | {
|
- | |
496 | float vid_wbyh = ((float)codec->width)/codec->height; |
518 | float vid_wbyh = ((float)codec->width)/codec->height; |
497 | float scr_wbyh = ((float)xdim)/ydim; |
519 | float scr_wbyh = ((float)xdim)/ydim; |
498 | 520 | ||
499 | float x=1.0, y=1.0; |
521 | float x=1.0, y=1.0; |
500 | #if 1
|
522 | #if 1
|
Line 508... | Line 530... | ||
508 | y = scr_wbyh/vid_wbyh; |
530 | y = scr_wbyh/vid_wbyh; |
509 | }
|
531 | }
|
510 | #endif
|
532 | #endif
|
511 | bglBegin(GL_QUADS); |
533 | bglBegin(GL_QUADS); |
512 | 534 | ||
- | 535 | if (!glinfo.glsl) |
|
- | 536 | bglColor3f(1.0, 1.0, 1.0); |
|
- | 537 | ||
513 | bglTexCoord2f(0.0,1.0); |
538 | bglTexCoord2f(0.0,1.0); |
514 | bglVertex3f(-x, -y, 0.0); |
539 | bglVertex3f(-x, -y, 0.0); |
515 | 540 | ||
516 | bglTexCoord2f(0.0,0.0); |
541 | bglTexCoord2f(0.0,0.0); |
517 | bglVertex3f(-x, y, 0.0); |
542 | bglVertex3f(-x, y, 0.0); |
Line 521... | Line 546... | ||
521 | 546 | ||
522 | bglTexCoord2f(1.0,1.0); |
547 | bglTexCoord2f(1.0,1.0); |
523 | bglVertex3f(x, -y, 0.0); |
548 | bglVertex3f(x, -y, 0.0); |
524 | 549 | ||
525 | bglEnd(); |
550 | bglEnd(); |
526 | }
|
- | |
527 | 551 | ||
528 | t = getticks()-t; |
552 | t = getticks()-t; |
529 | codec->sumtimes[2] += t; |
553 | codec->sumtimes[2] += t; |
530 | codec->maxtimes[2] = max(codec->maxtimes[2], t); |
554 | codec->maxtimes[2] = max(codec->maxtimes[2], t); |
531 | codec->numframes++; |
555 | codec->numframes++; |
Line 539... | Line 563... | ||
539 | {
|
563 | {
|
540 | const int32_t *s = codec->sumtimes; |
564 | const int32_t *s = codec->sumtimes; |
541 | const int32_t *m = codec->maxtimes; |
565 | const int32_t *m = codec->maxtimes; |
542 | int32_t n = codec->numframes; |
566 | int32_t n = codec->numframes; |
543 | 567 | ||
- | 568 | if (glinfo.glsl) |
|
- | 569 | initprintf("animvpx: GLSL mode\n"); |
|
- | 570 | ||
544 | initprintf("VP8 timing stats (mean, max) [ms] for %d frames:\n" |
571 | initprintf("VP8 timing stats (mean, max) [ms] for %d frames:\n" |
545 | " read and decode frame: %.02f, %d\n"
|
572 | " read and decode frame: %.02f, %d\n"
|
546 | " 3 planes -> packed conversion: %.02f, %d\n"
|
573 | " 3 planes -> packed conversion: %.02f, %d\n"
|
547 | " upload and display: %.02f, %d\n", |
574 | " upload and display: %.02f, %d\n", |
548 | n, (double)s[0]/n, m[0], (double)s[1]/n, m[1], (double)s[2]/n, m[2]); |
575 | n, (double)s[0]/n, m[0], (double)s[1]/n, m[1], (double)s[2]/n, m[2]); |