| 291 | | fmt.i_chroma = p_sys->b_text ? VLC_FOURCC('T','E','X','T') : VLC_FOURCC('R','G','B','A'); |
|---|
| | 310 | fmt.i_chroma = p_sys->b_text ? VLC_FOURCC('T','E','X','T') : |
|---|
| | 311 | #ifdef HAVE_FFMPEG_SWSCALE_H |
|---|
| | 312 | VLC_FOURCC('Y','U','V','A'); |
|---|
| | 313 | #else |
|---|
| | 314 | VLC_FOURCC('R','G','B','A'); |
|---|
| | 315 | #endif |
|---|
| 340 | | else |
|---|
| 341 | | { |
|---|
| 342 | | vbi_draw_vt_page( &p_page, VBI_PIXFMT_RGBA32_LE, |
|---|
| | 369 | else |
|---|
| | 370 | { |
|---|
| | 371 | #ifdef HAVE_FFMPEG_SWSCALE_H |
|---|
| | 372 | video_format_t fmt_in; |
|---|
| | 373 | picture_t *p_pic, *p_dest; |
|---|
| | 374 | |
|---|
| | 375 | p_pic = ( picture_t * ) malloc( sizeof( picture_t ) ); |
|---|
| | 376 | if( !p_pic ) |
|---|
| | 377 | { |
|---|
| | 378 | msg_Err( p_dec, "out of memory" ); |
|---|
| | 379 | goto error; |
|---|
| | 380 | } |
|---|
| | 381 | |
|---|
| | 382 | memset( &fmt_in, 0, sizeof( video_format_t ) ); |
|---|
| | 383 | memset( p_pic, 0, sizeof( picture_t ) ); |
|---|
| | 384 | |
|---|
| | 385 | fmt_in = p_spu->p_region->fmt; |
|---|
| | 386 | fmt_in.i_chroma = VLC_FOURCC('R','G','B','A'); |
|---|
| | 387 | |
|---|
| | 388 | vout_AllocatePicture( VLC_OBJECT(p_dec), p_pic, fmt_in.i_chroma, |
|---|
| | 389 | fmt_in.i_width, fmt_in.i_height, fmt_in.i_aspect ); |
|---|
| | 390 | |
|---|
| | 391 | if( !p_pic->i_planes ) |
|---|
| | 392 | { |
|---|
| | 393 | free( p_pic->p_data_orig ); |
|---|
| | 394 | free( p_pic ); |
|---|
| | 395 | goto error; |
|---|
| | 396 | } |
|---|
| | 397 | |
|---|
| | 398 | vbi_draw_vt_page( &p_page, ZVBI_PIXFMT_RGBA32, |
|---|
| | 399 | p_pic->p->p_pixels, 1, 1 ); |
|---|
| | 400 | |
|---|
| | 401 | p_pic->p->i_lines = p_page.rows * 10; |
|---|
| | 402 | p_pic->p->i_pitch = p_page.columns * 12 * 4; |
|---|
| | 403 | |
|---|
| | 404 | OpaquePage( p_dec, p_page, fmt_in, &p_pic ); |
|---|
| | 405 | |
|---|
| | 406 | #if 0 |
|---|
| | 407 | msg_Dbg( p_dec, "page %x-%x(%d,%d)", |
|---|
| | 408 | p_page.pgno, p_page.subno, |
|---|
| | 409 | p_page.rows, p_page.columns ); |
|---|
| | 410 | #endif |
|---|
| | 411 | p_dest = image_Convert( p_sys->p_image, p_pic, &fmt_in, |
|---|
| | 412 | &p_spu->p_region->fmt ); |
|---|
| | 413 | if( !p_dest ) |
|---|
| | 414 | { |
|---|
| | 415 | free( p_pic->p_data_orig ); |
|---|
| | 416 | free( p_pic ); |
|---|
| | 417 | msg_Err( p_dec, "chroma conversion failed" ); |
|---|
| | 418 | goto error; |
|---|
| | 419 | } |
|---|
| | 420 | |
|---|
| | 421 | vout_CopyPicture( VLC_OBJECT(p_dec), &p_spu->p_region->picture, |
|---|
| | 422 | p_dest ); |
|---|
| | 423 | |
|---|
| | 424 | free( p_pic->p_data_orig ); |
|---|
| | 425 | free( p_pic ); |
|---|
| | 426 | |
|---|
| | 427 | free( p_dest->p_data_orig ); |
|---|
| | 428 | free( p_dest ); |
|---|
| | 429 | #else |
|---|
| | 430 | picture_t *p_pic; |
|---|
| | 431 | |
|---|
| | 432 | vbi_draw_vt_page( &p_page, ZVBI_PIXFMT_RGBA32, |
|---|
| 346 | | } |
|---|
| 347 | | |
|---|
| 348 | | /* Kludge since zvbi doesn't provide an option to specify opacity. */ |
|---|
| 349 | | if( p_sys->b_opaque && !p_sys->b_text ) |
|---|
| 350 | | { |
|---|
| 351 | | p_begin = (uint32_t *)p_spu->p_region->picture.p->p_pixels; |
|---|
| 352 | | p_end = (uint32_t *)p_spu->p_region->picture.p->p_pixels+(fmt.i_width * fmt.i_height); |
|---|
| 353 | | |
|---|
| 354 | | for( ; p_begin < p_end; p_begin++ ) |
|---|
| 355 | | { |
|---|
| 356 | | opacity = p_page.text[ y / 10 * p_page.columns + x / 12 ].opacity; |
|---|
| 357 | | switch( opacity ) |
|---|
| 358 | | { |
|---|
| 359 | | /* Show video instead of this character */ |
|---|
| 360 | | case VBI_TRANSPARENT_SPACE: |
|---|
| 361 | | *p_begin = 0; |
|---|
| 362 | | break; |
|---|
| 363 | | /* To make the boxed text "closed captioning" transparent |
|---|
| 364 | | * change VLC_TRUE to VLC_FALSE. |
|---|
| 365 | | */ |
|---|
| 366 | | case VBI_OPAQUE: |
|---|
| 367 | | if( p_sys->b_opaque ) |
|---|
| 368 | | break; |
|---|
| 369 | | /* Full text transparency. only foreground color is show */ |
|---|
| 370 | | case VBI_TRANSPARENT_FULL: |
|---|
| 371 | | /* Transparency for boxed text */ |
|---|
| 372 | | case VBI_SEMI_TRANSPARENT: |
|---|
| 373 | | if( (*p_begin & 0xffffff00) == 0xff ) |
|---|
| 374 | | *p_begin = 0; |
|---|
| 375 | | break; |
|---|
| 376 | | default: |
|---|
| 377 | | break; |
|---|
| 378 | | } |
|---|
| 379 | | x++; |
|---|
| 380 | | if( x >= fmt.i_width ) |
|---|
| 381 | | { |
|---|
| 382 | | x = 0; |
|---|
| 383 | | y++; |
|---|
| 384 | | } |
|---|
| 385 | | } |
|---|
| 386 | | } |
|---|
| 387 | | /* end of kludge */ |
|---|
| | 437 | |
|---|
| | 438 | p_pic = &(p_spu->p_region->picture); |
|---|
| | 439 | OpaquePage( p_dec, p_page, fmt, &p_pic ); |
|---|
| | 440 | #endif |
|---|
| | 441 | } |
|---|
| | 442 | |
|---|
| | 443 | #undef PIXFMT_RGBA32 |
|---|
| | 490 | static int OpaquePage( decoder_t *p_dec, vbi_page p_page, |
|---|
| | 491 | video_format_t fmt, picture_t **p_src ) |
|---|
| | 492 | { |
|---|
| | 493 | decoder_sys_t *p_sys = (decoder_sys_t *) p_dec->p_sys; |
|---|
| | 494 | uint32_t *p_begin, *p_end; |
|---|
| | 495 | unsigned int x = 0, y = 0; |
|---|
| | 496 | vbi_opacity opacity; |
|---|
| | 497 | |
|---|
| | 498 | /* Kludge since zvbi doesn't provide an option to specify opacity. */ |
|---|
| | 499 | if( ( fmt.i_chroma != VLC_FOURCC('R','G','B','A' ) ) && |
|---|
| | 500 | ( fmt.i_chroma != VLC_FOURCC('Y','U','V','A' ) ) ) |
|---|
| | 501 | { |
|---|
| | 502 | msg_Err( p_dec, "chroma not supported %4.4s", (char *)&fmt.i_chroma ); |
|---|
| | 503 | return VLC_EGENERIC; |
|---|
| | 504 | } |
|---|
| | 505 | |
|---|
| | 506 | switch( fmt.i_chroma ) |
|---|
| | 507 | { |
|---|
| | 508 | case VLC_FOURCC('R','G','B','A' ): |
|---|
| | 509 | p_begin = (uint32_t *)(*p_src)->p->p_pixels; |
|---|
| | 510 | p_end = (uint32_t *)(*p_src)->p->p_pixels+(fmt.i_width * fmt.i_height); |
|---|
| | 511 | break; |
|---|
| | 512 | case VLC_FOURCC('Y','U','V','A' ): |
|---|
| | 513 | p_begin = (uint32_t *)(*p_src)->p[A_PLANE].p_pixels; |
|---|
| | 514 | p_end = (uint32_t *)(*p_src)->p[A_PLANE].p_pixels + |
|---|
| | 515 | ( (*p_src)->p[A_PLANE].i_lines * (*p_src)->p[A_PLANE].i_pitch ); |
|---|
| | 516 | break; |
|---|
| | 517 | default: |
|---|
| | 518 | msg_Err( p_dec, "chroma not supported %4.4s", (char *)&fmt.i_chroma ); |
|---|
| | 519 | return VLC_EGENERIC; |
|---|
| | 520 | } |
|---|
| | 521 | |
|---|
| | 522 | for( ; p_begin < p_end; p_begin++ ) |
|---|
| | 523 | { |
|---|
| | 524 | opacity = p_page.text[ y / 10 * p_page.columns + x / 12 ].opacity; |
|---|
| | 525 | switch( opacity ) |
|---|
| | 526 | { |
|---|
| | 527 | /* Show video instead of this character */ |
|---|
| | 528 | case VBI_TRANSPARENT_SPACE: |
|---|
| | 529 | *p_begin = 0; |
|---|
| | 530 | break; |
|---|
| | 531 | /* To make the boxed text "closed captioning" transparent |
|---|
| | 532 | * change VLC_TRUE to VLC_FALSE. |
|---|
| | 533 | */ |
|---|
| | 534 | case VBI_OPAQUE: |
|---|
| | 535 | if( p_sys->b_opaque ) |
|---|
| | 536 | break; |
|---|
| | 537 | /* Full text transparency. only foreground color is show */ |
|---|
| | 538 | case VBI_TRANSPARENT_FULL: |
|---|
| | 539 | /* Transparency for boxed text */ |
|---|
| | 540 | case VBI_SEMI_TRANSPARENT: |
|---|
| | 541 | if( (*p_begin & 0xffffff00) == 0xff ) |
|---|
| | 542 | *p_begin = 0; |
|---|
| | 543 | break; |
|---|
| | 544 | default: |
|---|
| | 545 | break; |
|---|
| | 546 | } |
|---|
| | 547 | x++; |
|---|
| | 548 | if( x >= fmt.i_width ) |
|---|
| | 549 | { |
|---|
| | 550 | x = 0; |
|---|
| | 551 | y++; |
|---|
| | 552 | } |
|---|
| | 553 | } |
|---|
| | 554 | /* end of kludge */ |
|---|
| | 555 | return VLC_SUCCESS; |
|---|
| | 556 | } |
|---|
| | 557 | |
|---|