00001
00017 #include "contributors.h"
00018 #include "global.h"
00019
00020 byte assignSE2partition[][SE_MAX_ELEMENTS] =
00021 {
00022
00023 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
00024 { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 0, 0, 0 }
00025 };
00026
00041 int RBSPtoSODB(byte *streamBuffer, int last_byte_pos)
00042 {
00043 int ctr_bit, bitoffset;
00044
00045 bitoffset = 0;
00046
00047 ctr_bit = (streamBuffer[last_byte_pos-1] & (0x01<<bitoffset));
00048
00049 while (ctr_bit==0)
00050 {
00051 bitoffset++;
00052 if(bitoffset == 8)
00053 {
00054 if(last_byte_pos == 0)
00055 printf(" Panic: All zero data sequence in RBSP \n");
00056 assert(last_byte_pos != 0);
00057 last_byte_pos -= 1;
00058 bitoffset = 0;
00059 }
00060 ctr_bit= streamBuffer[last_byte_pos-1] & (0x01<<(bitoffset));
00061 }
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 return(last_byte_pos);
00075
00076 }
00077
00078
00092 int EBSPtoRBSP(byte *streamBuffer, int end_bytepos, int begin_bytepos)
00093 {
00094 int i, j, count;
00095 count = 0;
00096
00097 if(end_bytepos < begin_bytepos)
00098 return end_bytepos;
00099
00100 j = begin_bytepos;
00101
00102 for(i = begin_bytepos; i < end_bytepos; i++)
00103 {
00104
00105 if(count == ZEROBYTES_SHORTSTARTCODE && streamBuffer[i] < 0x03)
00106 return -1;
00107 if(count == ZEROBYTES_SHORTSTARTCODE && streamBuffer[i] == 0x03)
00108 {
00109
00110 if((i < end_bytepos-1) && (streamBuffer[i+1] > 0x03))
00111 return -1;
00112
00113 if(i == end_bytepos-1)
00114 return j;
00115
00116 i++;
00117 count = 0;
00118 }
00119 streamBuffer[j] = streamBuffer[i];
00120 if(streamBuffer[i] == 0x00)
00121 count++;
00122 else
00123 count = 0;
00124 j++;
00125 }
00126
00127 return j;
00128 }