Opened 14 years ago Closed 14 years ago #148 closed defect (fixed)Fix RBSP emulation
Description
The HM encoder currently fails to perform startcode emulation prevention on all NAL units.
Worse, the current method of doing this has lead to some horrible hacks to signal where slices start so that the anti-emulation code can skip over the startcodes.
A solution is to assemble separate NALunits (this also allows for trivial reordering of the NALunits in cases where SEI messages are calculated after the picture has been encoded) and deal with them as a vector (much like writev(2)). Change History (7)comment:1 Changed 14 years ago by davidf
comment:2 Changed 14 years ago by hao
The current HM-3.0-dev r909 software still has another emulation problem. ... for (vector<uint8_t>::const_iterator it = rbsp.begin(); it != rbsp.end();) { /* 1) find the next emulated start_code_prefix * 2a) if not found, write all remaining bytes out, stop. * 2b) otherwise, write all non-emulated bytes out * 3) insert emulation_prevention_three_byte */ #if FIX_EMULATION_PREVENTION_EMULATION static const uint8_t two_zero_bytes[] = {0,0}; vector<uint8_t>::const_iterator curr_it = it; vector<uint8_t>::const_iterator found; bool end_search = false; do { found = search(curr_it, rbsp.end(), two_zero_bytes, two_zero_bytes+2); unsigned num_last_bytes = rbsp.end() - found; if ( num_last_bytes >= 3 && *(found+2) > 0x3 ) { curr_it += 3; } else { end_search = true; } } while ( !end_search ); #else static const char start_code_prefix[] = {0,0,1}; vector<uint8_t>::const_iterator found = search(it, rbsp.end(), start_code_prefix, start_code_prefix+3); #endif unsigned num_nonemulated_bytes = found - it; ... comment:3 Changed 14 years ago by hao
Sorry, not low complexity but high efficiency. comment:4 Changed 14 years ago by davidf
It looks like i was too literal when i wrote down prevent emulation of "start_code_prefix".
Using the following test cases, this has now been resolved in r917: Self-Test: 0, {ff,ff,ff,ff} -> {ff,ff,ff,ff} OK Self-Test: 1, {ff,ff,ff,ff,0,0,0} -> {ff,ff,ff,ff,0,0,3,0,3} OK Self-Test: 2, {ff,ff,ff,ff,0,0,1} -> {ff,ff,ff,ff,0,0,3,1} OK Self-Test: 3, {ff,ff,ff,ff,0,0,2} -> {ff,ff,ff,ff,0,0,3,2} OK Self-Test: 4, {ff,ff,ff,ff,0,0,3} -> {ff,ff,ff,ff,0,0,3,3} OK Self-Test: 5, {ff,ff,ff,ff,0,0,4} -> {ff,ff,ff,ff,0,0,4} OK Self-Test: 6, {ff,ff,ff,ff,0,0,0,ff,ff} -> {ff,ff,ff,ff,0,0,3,0,ff,ff} OK Self-Test: 7, {ff,ff,ff,ff,0,0,1,ff,ff} -> {ff,ff,ff,ff,0,0,3,1,ff,ff} OK Self-Test: 8, {ff,ff,ff,ff,0,0,2,ff,ff} -> {ff,ff,ff,ff,0,0,3,2,ff,ff} OK Self-Test: 9, {ff,ff,ff,ff,0,0,3,ff,ff} -> {ff,ff,ff,ff,0,0,3,3,ff,ff} OK Self-Test: a, {ff,ff,ff,ff,0,0,4,ff,ff} -> {ff,ff,ff,ff,0,0,4,ff,ff} OK Self-Test: b, {ff,ff,ff,ff,0,0,0,0,0,0,ff,ff} -> {ff,ff,ff,ff,0,0,3,0,0,3,0,0,ff,ff} OK Self-Test: c, {ff,ff,ff,ff,0,0,1,0,0,1,ff,ff} -> {ff,ff,ff,ff,0,0,3,1,0,0,3,1,ff,ff} OK Self-Test: d, {ff,ff,ff,ff,0,0,2,0,0,2,ff,ff} -> {ff,ff,ff,ff,0,0,3,2,0,0,3,2,ff,ff} OK Self-Test: e, {ff,ff,ff,ff,0,0,3,0,0,3,ff,ff} -> {ff,ff,ff,ff,0,0,3,3,0,0,3,3,ff,ff} OK Self-Test: f, {ff,ff,ff,ff,0,0,4,0,0,4,ff,ff} -> {ff,ff,ff,ff,0,0,4,0,0,4,ff,ff} OK Self-Test: 10, {ff,ff,ff,ff,0} -> {ff,ff,ff,ff,0,3} OK Self-Test: 11, {ff,ff,ff,ff,0,0} -> {ff,ff,ff,ff,0,0,3} OK Self-Test: 12, {ff,ff,ff,ff,0,0,0} -> {ff,ff,ff,ff,0,0,3,0,3} OK Self-Test: 13, {ff} -> {ff} OK comment:5 Changed 13 years ago by davidf
Updating component after adding WD (Text) tickets comment:6 Changed 13 years ago by davidf
comment:7 Changed 13 years ago by davidf
Note: See
TracTickets for help on using
tickets. | This list contains all users that will be notified about changes made to this ticket. These roles will be notified: Reporter, Owner, Subscriber, Participant
|
This has been resolved in HM-3.0-dev r867:909