Changeset e114bdd7ffd180a04bf83e8c1af5c4132a3771ad
- Timestamp:
- 21/08/08 19:08:54
(3 months ago)
- Author:
- Laurent Aimar <fenrir@videolan.org>
- git-committer:
- Laurent Aimar <fenrir@videolan.org> 1219338534 +0200
- git-parent:
[0bf165646d0dd39ad1bc698cdde0bbff1711e24d]
- git-author:
- Laurent Aimar <fenrir@videolan.org> 1219338381 +0200
- Message:
Added BLOCK_FLAG_END_OF_SEQUENCE and use it for mpeg2.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rebd8003 |
re114bdd |
|
| 69 | 69 | /** This is not a key frame for bitrate shaping */ |
|---|
| 70 | 70 | #define BLOCK_FLAG_NO_KEYFRAME 0x0080 |
|---|
| | 71 | /** This block contains the last part of a sequence */ |
|---|
| | 72 | #define BLOCK_FLAG_END_OF_SEQUENCE 0x0100 |
|---|
| 71 | 73 | /** This block contains a clock reference */ |
|---|
| 72 | 74 | #define BLOCK_FLAG_CLOCK 0x0200 |
|---|
| ra827517 |
re114bdd |
|
| 82 | 82 | int i_buffer_orig, i_buffer; |
|---|
| 83 | 83 | char *p_buffer_orig, *p_buffer; |
|---|
| | 84 | |
|---|
| | 85 | |
|---|
| | 86 | /* */ |
|---|
| | 87 | bool b_flush; |
|---|
| 84 | 88 | }; |
|---|
| 85 | 89 | |
|---|
| … | … | |
| 319 | 323 | p_sys->b_has_b_frames = false; |
|---|
| 320 | 324 | p_sys->b_first_frame = true; |
|---|
| | 325 | p_sys->b_flush = false; |
|---|
| 321 | 326 | p_sys->i_late_frames = 0; |
|---|
| 322 | 327 | p_sys->i_buffer = 0; |
|---|
| … | … | |
| 479 | 484 | if( p_block->i_buffer > 0 ) |
|---|
| 480 | 485 | { |
|---|
| | 486 | p_sys->b_flush = ( p_block->i_flags & BLOCK_FLAG_END_OF_SEQUENCE ) != 0; |
|---|
| | 487 | |
|---|
| 481 | 488 | p_sys->i_buffer = p_block->i_buffer; |
|---|
| 482 | 489 | if( p_sys->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE > |
|---|
| … | … | |
| 502 | 509 | } |
|---|
| 503 | 510 | |
|---|
| 504 | | while( p_sys->i_buffer > 0 ) |
|---|
| | 511 | while( p_sys->i_buffer > 0 || p_sys->b_flush ) |
|---|
| 505 | 512 | { |
|---|
| 506 | 513 | int i_used, b_gotpicture; |
|---|
| … | … | |
| 509 | 516 | i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic, |
|---|
| 510 | 517 | &b_gotpicture, |
|---|
| 511 | | (uint8_t*)p_sys->p_buffer, p_sys->i_buffer ); |
|---|
| | 518 | p_sys->i_buffer <= 0 && p_sys->b_flush ? NULL : (uint8_t*)p_sys->p_buffer, p_sys->i_buffer ); |
|---|
| | 519 | |
|---|
| 512 | 520 | if( b_null_size && p_sys->p_context->width > 0 && |
|---|
| 513 | | p_sys->p_context->height > 0 ) |
|---|
| | 521 | p_sys->p_context->height > 0 && |
|---|
| | 522 | !p_sys->b_flush ) |
|---|
| 514 | 523 | { |
|---|
| 515 | 524 | /* Reparse it to not drop the I frame */ |
|---|
| … | … | |
| 522 | 531 | } |
|---|
| 523 | 532 | |
|---|
| | 533 | if( p_sys->b_flush ) |
|---|
| | 534 | p_sys->b_first_frame = true; |
|---|
| | 535 | |
|---|
| | 536 | if( p_sys->i_buffer <= 0 ) |
|---|
| | 537 | p_sys->b_flush = false; |
|---|
| | 538 | |
|---|
| 524 | 539 | if( i_used < 0 ) |
|---|
| 525 | 540 | { |
|---|
| … | … | |
| 537 | 552 | p_sys->i_buffer -= i_used; |
|---|
| 538 | 553 | p_sys->p_buffer += i_used; |
|---|
| | 554 | |
|---|
| | 555 | p_sys->b_first_frame = true; |
|---|
| 539 | 556 | |
|---|
| 540 | 557 | /* Nothing to display */ |
|---|
| r3561b9b |
re114bdd |
|
| 446 | 446 | (p_frag->p_buffer[3] == 0x00 || p_frag->p_buffer[3] > 0xaf) ) |
|---|
| 447 | 447 | { |
|---|
| | 448 | const bool b_eos = p_frag->p_buffer[3] == 0xb7; |
|---|
| | 449 | |
|---|
| 448 | 450 | mtime_t i_duration; |
|---|
| 449 | 451 | |
|---|
| | 452 | if( b_eos ) |
|---|
| | 453 | { |
|---|
| | 454 | block_ChainLastAppend( &p_sys->pp_last, p_frag ); |
|---|
| | 455 | p_frag = NULL; |
|---|
| | 456 | } |
|---|
| | 457 | |
|---|
| 450 | 458 | p_pic = block_ChainGather( p_sys->p_frame ); |
|---|
| | 459 | |
|---|
| | 460 | if( b_eos ) |
|---|
| | 461 | p_pic->i_flags |= BLOCK_FLAG_END_OF_SEQUENCE; |
|---|
| 451 | 462 | |
|---|
| 452 | 463 | i_duration = (mtime_t)( 1000000 * p_sys->i_frame_rate_base / |
|---|
| … | … | |
| 564 | 575 | } |
|---|
| 565 | 576 | |
|---|
| | 577 | if( !p_frag ) |
|---|
| | 578 | return p_pic; |
|---|
| 566 | 579 | /* |
|---|
| 567 | 580 | * Check info of current fragment |
|---|