⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 put.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
0x0000002c, 0x00000001, 0x00000006, 0x0000002d, 0x00000001, 0xfffffffa, 0x0000002a, 0x00000001, 0x00000007,0x0000002b, 0x00000001, 0xfffffff9, 0x00000028, 0x00000002, 0x00000005, 0x00000029, 0x00000002, 0xfffffffb,0x00000026, 0x00000003, 0x00000004, 0x00000027, 0x00000003, 0xfffffffc, 0x00000024, 0x00000005, 0x00000003,0x00000025, 0x00000005, 0xfffffffd, 0x00000022, 0x00000009, 0x00000002, 0x00000023, 0x00000009, 0xfffffffe,0x00000020, 0x0000000a, 0x00000002, 0x00000021, 0x0000000a, 0xfffffffe, 0x0000003e, 0x00000016, 0x00000001,0x0000003f, 0x00000016, 0xffffffff, 0x0000003c, 0x00000017, 0x00000001, 0x0000003d, 0x00000017, 0xffffffff,0x0000003a, 0x00000018, 0x00000001, 0x0000003b, 0x00000018, 0xffffffff, 0x00000038, 0x00000019, 0x00000001,0x00000039, 0x00000019, 0xffffffff, 0x00000036, 0x0000001a, 0x00000001, 0x00000037, 0x0000001a, 0xffffffff, 32, /* 15-bit codes */0x0000003e, 0x00000000, 0x00000010, 0x0000003f, 0x00000000, 0xfffffff0, 0x0000003c, 0x00000000, 0x00000011,0x0000003d, 0x00000000, 0xffffffef, 0x0000003a, 0x00000000, 0x00000012, 0x0000003b, 0x00000000, 0xffffffee,0x00000038, 0x00000000, 0x00000013, 0x00000039, 0x00000000, 0xffffffed, 0x00000036, 0x00000000, 0x00000014,0x00000037, 0x00000000, 0xffffffec, 0x00000034, 0x00000000, 0x00000015, 0x00000035, 0x00000000, 0xffffffeb,0x00000032, 0x00000000, 0x00000016, 0x00000033, 0x00000000, 0xffffffea, 0x00000030, 0x00000000, 0x00000017,0x00000031, 0x00000000, 0xffffffe9, 0x0000002e, 0x00000000, 0x00000018, 0x0000002f, 0x00000000, 0xffffffe8,0x0000002c, 0x00000000, 0x00000019, 0x0000002d, 0x00000000, 0xffffffe7, 0x0000002a, 0x00000000, 0x0000001a,0x0000002b, 0x00000000, 0xffffffe6, 0x00000028, 0x00000000, 0x0000001b, 0x00000029, 0x00000000, 0xffffffe5,0x00000026, 0x00000000, 0x0000001c, 0x00000027, 0x00000000, 0xffffffe4, 0x00000024, 0x00000000, 0x0000001d,0x00000025, 0x00000000, 0xffffffe3, 0x00000022, 0x00000000, 0x0000001e, 0x00000023, 0x00000000, 0xffffffe2,0x00000020, 0x00000000, 0x0000001f, 0x00000021, 0x00000000, 0xffffffe1, 32, /* 16-bit codes */0x00000030, 0x00000000, 0x00000020, 0x00000031, 0x00000000, 0xffffffe0, 0x0000002e, 0x00000000, 0x00000021,0x0000002f, 0x00000000, 0xffffffdf, 0x0000002c, 0x00000000, 0x00000022, 0x0000002d, 0x00000000, 0xffffffde,0x0000002a, 0x00000000, 0x00000023, 0x0000002b, 0x00000000, 0xffffffdd, 0x00000028, 0x00000000, 0x00000024,0x00000029, 0x00000000, 0xffffffdc, 0x00000026, 0x00000000, 0x00000025, 0x00000027, 0x00000000, 0xffffffdb,0x00000024, 0x00000000, 0x00000026, 0x00000025, 0x00000000, 0xffffffda, 0x00000022, 0x00000000, 0x00000027,0x00000023, 0x00000000, 0xffffffd9, 0x00000020, 0x00000000, 0x00000028, 0x00000021, 0x00000000, 0xffffffd8,0x0000003e, 0x00000001, 0x00000008, 0x0000003f, 0x00000001, 0xfffffff8, 0x0000003c, 0x00000001, 0x00000009,0x0000003d, 0x00000001, 0xfffffff7, 0x0000003a, 0x00000001, 0x0000000a, 0x0000003b, 0x00000001, 0xfffffff6,0x00000038, 0x00000001, 0x0000000b, 0x00000039, 0x00000001, 0xfffffff5, 0x00000036, 0x00000001, 0x0000000c,0x00000037, 0x00000001, 0xfffffff4, 0x00000034, 0x00000001, 0x0000000d, 0x00000035, 0x00000001, 0xfffffff3,0x00000032, 0x00000001, 0x0000000e, 0x00000033, 0x00000001, 0xfffffff2, 32, /* 17-bit codes */0x00000026, 0x00000001, 0x0000000f, 0x00000027, 0x00000001, 0xfffffff1, 0x00000024, 0x00000001, 0x00000010,0x00000025, 0x00000001, 0xfffffff0, 0x00000022, 0x00000001, 0x00000011, 0x00000023, 0x00000001, 0xffffffef,0x00000020, 0x00000001, 0x00000012, 0x00000021, 0x00000001, 0xffffffee, 0x00000028, 0x00000006, 0x00000003,0x00000029, 0x00000006, 0xfffffffd, 0x00000034, 0x0000000b, 0x00000002, 0x00000035, 0x0000000b, 0xfffffffe,0x00000032, 0x0000000c, 0x00000002, 0x00000033, 0x0000000c, 0xfffffffe, 0x00000030, 0x0000000d, 0x00000002,0x00000031, 0x0000000d, 0xfffffffe, 0x0000002e, 0x0000000e, 0x00000002, 0x0000002f, 0x0000000e, 0xfffffffe,0x0000002c, 0x0000000f, 0x00000002, 0x0000002d, 0x0000000f, 0xfffffffe, 0x0000002a, 0x00000010, 0x00000002,0x0000002b, 0x00000010, 0xfffffffe, 0x0000003e, 0x0000001b, 0x00000001, 0x0000003f, 0x0000001b, 0xffffffff,0x0000003c, 0x0000001c, 0x00000001, 0x0000003d, 0x0000001c, 0xffffffff, 0x0000003a, 0x0000001d, 0x00000001,0x0000003b, 0x0000001d, 0xffffffff, 0x00000038, 0x0000001e, 0x00000001, 0x00000039, 0x0000001e, 0xffffffff,0x00000036, 0x0000001f, 0x00000001, 0x00000037, 0x0000001f, 0xffffffff,-1 /* end of table */};const IppiPoint ippMPEG2VideoEncoder::MV_ZERO = {0, 0};// generate sequence header (6.2.2.1, 6.3.3)void ippMPEG2VideoEncoder::PutSequenceHeader(){    int i;    PUT_START_CODE(SEQ_START_CODE);               // sequence_header_code    PUT_BITS(srcYFrameHSize, 12);                 // horizontal_size_value    PUT_BITS(srcYFrameVSize, 12);                 // vertical_size_value    PUT_BITS(encodeInfo.aspectRatio, 4);          // aspect_ratio_information    PUT_BITS(encodeInfo.frame_rate_code, 4);      // frame_rate_code    if(BitRate <= 0) {      PUT_BITS(4000000/400, 18);                  // arbitrary bit_rate_value    } else {      PUT_BITS((int)ceil(BitRate / 400.0), 18);   // bit_rate_value    }    PUT_BITS(1, 1);                               // marker_bit    PUT_BITS(encodeInfo.VBV_BufferSize, 10);      // vbv_buffer_size_value    PUT_BITS(0, 1);                               // constrained_parameters_flag    PUT_BITS(encodeInfo.CustomIntraQMatrix, 1);   // load_intra_quantizer_matrix    if( encodeInfo.CustomIntraQMatrix )        for(i=0; i < 64; i++) // matrices are always downloaded in zig-zag order            PUT_BITS(IntraQMatrix[ZigZagScan[i]], 8);    // intra_quantizer_matrix    PUT_BITS(encodeInfo.CustomNonIntraQMatrix, 1);       // load_non_intra_quantizer_matrix    if( encodeInfo.CustomNonIntraQMatrix )        for(i=0; i < 64; i++)            PUT_BITS(NonIntraQMatrix[ZigZagScan[i]], 8); // non_intra_quantizer_matrix}// generate sequence extension (6.2.2.3, 6.3.5) header (MPEG-2 only)void ippMPEG2VideoEncoder::PutSequenceExt(){    PUT_START_CODE(EXT_START_CODE);         // extension_start_code    PUT_BITS(SEQ_ID, 4);                    // extension_start_code_identifier    PUT_BITS(( encodeInfo.ProfileID << 4 ) | encodeInfo.LevelID, 8);    // profile_and_level_indication    PUT_BITS(encodeInfo.prog_seq, 1);       // progressive sequence    PUT_BITS(encodeInfo.chroma_format, 2);  // chroma_format    PUT_BITS(srcYFrameHSize >> 12, 2);      // horizontal_size_extension    PUT_BITS(srcYFrameVSize >> 12, 2);      // vertical_size_extension    PUT_BITS(((int)ceil(BitRate / 400.0)) >> 18, 12);      // bit_rate_extension    PUT_BITS(1, 1);                         // marker_bit    PUT_BITS(encodeInfo.VBV_BufferSize >> 10, 8);          // vbv_buffer_size_extension    PUT_BITS(0, 1);                         // low_delay  (not implemented)    PUT_BITS(0, 2);                         // frame_rate_extension_n    PUT_BITS(0, 5);                         // frame_rate_extension_d}// generate sequence display extension (6.2.2.4, 6.3.6)void ippMPEG2VideoEncoder::PutSequenceDisplayExt(){    PUT_START_CODE(EXT_START_CODE); // extension_start_code    PUT_BITS(DISP_ID, 4);           // extension_start_code_identifier    PUT_BITS(1, 3);     // video_format    PUT_BITS(1, 1);     // colour_description    PUT_BITS(5, 8);     // colour_primaries    PUT_BITS(5, 8);     // transfer_characteristics    PUT_BITS(5, 8);     // matrix_coefficients    PUT_BITS(srcYFrameHSize, 14);  // display_horizontal_size    PUT_BITS(1, 1);                // marker_bit    PUT_BITS(srcYFrameVSize, 14);  // display_vertical_size}// put a zero terminated string as user data (6.2.2.2.2, 6.3.4.1)void ippMPEG2VideoEncoder::PutUserData(){    vm_char* UserData = encodeInfo.idStr;    PUT_START_CODE(USER_START_CODE); // user_data_start_code    while( *UserData ) {        PUT_BITS((Ipp8u)(*UserData), 8);        UserData++;    }}// generate group of pictures header (6.2.2.6, 6.3.9)void ippMPEG2VideoEncoder::PutGOPHeader(int Count ){    int tc;    PUT_START_CODE(GOP_START_CODE); // group_start_code    tc = FrameToTimecode(Count);    PUT_BITS(tc, 25);               // time_code    tc = (Count?1:0);    PUT_BITS(tc, 1);                // closed_gop (all exept first GOP are open)    PUT_BITS(0, 1);                 // broken_link}int ippMPEG2VideoEncoder::FrameToTimecode(int frame){    int fps, pict, sec, minute, hour, tc;    fps = (int)(FrameRate + 0.5);    pict = frame % fps;    frame = (frame - pict) / fps;    sec = frame % 60;    frame = (frame - sec) / 60;    minute = frame % 60;    frame = (frame - minute) / 60;    hour = frame % 24;    tc = (hour<<19) | (minute<<13) | (1<<12) | (sec<<6) | pict;    return tc;}// generate picture header (6.2.3, 6.3.9)void ippMPEG2VideoEncoder::PutPictureHeader(){    PUT_START_CODE(PICTURE_START_CODE);     // picture_start_code    PUT_BITS((temporal_reference & 0x3ff), 10);       // temporal_reference    PUT_BITS(picture_coding_type, 3);       // picture_coding_type    PUT_BITS(vbv_delay, 16);                // vbv_delay    if( picture_coding_type == P_TYPE || picture_coding_type == B_TYPE )    {        PUT_BITS(0, 1);                 // full_pel_forward_vector        PUT_BITS(7, 3);                 // forward_f_code    }    if( picture_coding_type == B_TYPE )    {        PUT_BITS(0, 1);                 // full_pel_backward_vector        PUT_BITS(7, 3);                 // backward_f_code    }    PUT_BITS(0, 1);                     // extra_bit_picture}// generate picture coding extension (6.2.3.1, 6.3.11)void ippMPEG2VideoEncoder::PutPictureCodingExt(){    PUT_START_CODE(EXT_START_CODE);     // extension_start_code    PUT_BITS(CODING_ID, 4);             // extension_start_code_identifier    PUT_BITS(forw_hor_f_code, 4);       // forward_horizontal_f_code    PUT_BITS(forw_vert_f_code, 4);      // forward_vertical_f_code    PUT_BITS(back_hor_f_code, 4);       // backward_horizontal_f_code    PUT_BITS(back_vert_f_code, 4);      // backward_vertical_f_code    PUT_BITS(encodeInfo.intra_dc_precision, 2); // encodeInfo.intra_dc_precision    PUT_BITS(picture_structure, 2);     // picture_structure    PUT_BITS((picture_structure == FRAME_PICTURE) ? encodeInfo.top_field_first : 0, 1);// top_field_first    PUT_BITS(curr_frame_pred, 1)        // frame_pred_frame_dct    PUT_BITS(0, 1);                     // concealment_motion_vectors (not implemented yet)    PUT_BITS(q_scale_type, 1);          // q_scale_type    PUT_BITS(curr_intra_vlc_format, 1); // intra_vlc_format    PUT_BITS(curr_scan, 1);             // alternate_scan    PUT_BITS(encodeInfo.repeat_first_field, 1); // repeat_first_field    PUT_BITS(((encodeInfo.chroma_format == CHROMA420) ? encodeInfo.progressive_frame : 0), 1); // chroma_420_type    PUT_BITS(encodeInfo.progressive_frame, 1);  // progressive_frame    PUT_BITS(0, 1);                     // composite_display_flag    // composite display information not implemented yet}// generate sequence_end_code (6.2.2)void ippMPEG2VideoEncoder::PutSequenceEnd(){    PUT_START_CODE(SEQ_END_CODE);}// slice header (6.2.4)void ippMPEG2VideoEncoder::PutSliceHeader(int RowNumber, int numTh){    if( srcYFrameVSize <= 2800 )    {        PUT_START_CODE_TH(numTh, SLICE_MIN_START + RowNumber); // slice_start_code    }    else    {        PUT_START_CODE_TH(numTh, SLICE_MIN_START + (RowNumber & 127)); // slice_start_code        PUT_BITS_TH(RowNumber >> 7, 3); // slice_vertical_position_extension    }    PUT_BITS_TH((quantiser_scale_code<<1), (5+1)); // + extra_bit_slice}// put variable length code for macroblock_address_increment (6.3.17)void ippMPEG2VideoEncoder::PutAddrIncrement(int increment, int numTh ){    while( increment > 33 )    {        PUT_BITS_TH(0x08, 11); // put macroblock_escape        increment -= 33;    }    PUT_BITS_TH(AddrIncrementTbl[increment].code, AddrIncrementTbl[increment].len);}void ippMPEG2VideoEncoder::PutMV(Ipp32s delta, Ipp32s f_code, int numTh){    Ipp32s f, r_size, low, high, range , temp, motion_code, motion_residual;    Ipp32s tpos; // LUT position    r_size = f_code - 1;    f = 1<<r_size;    low   = -16*f;    high  = 16*f - 1;    range = 32*f;    /* fold vector difference into [vmin...vmax] */    if(delta > high)     delta -= range;    else if(delta < low) delta += range;    /* check value */    mpeg2_assert(delta >= low);    mpeg2_assert(delta <= high);    if(f == 1 || delta == 0)    {        PUT_BITS_TH(MV_VLC_Tbl[16 + delta].code, MV_VLC_Tbl[16 + delta].len);        return;    }    // present delta as motion_code and motion_residual    if( delta < 0 )    {        temp = -delta + f - 1;        motion_code = temp >> r_size;        tpos = 16 - motion_code;    }    else // delta > 0    {        temp = delta + f - 1;        motion_code = temp >> r_size;        tpos = 16 + motion_code;    }    mpeg2_assert(motion_code > 0 && motion_code <= 16);    // put variable length code for motion_code (6.3.16.3)    // put fixed length code for motion_residual    motion_residual = (MV_VLC_Tbl[tpos].code << r_size) + (temp & (f - 1));    r_size += MV_VLC_Tbl[tpos].len;    PUT_BITS_TH(motion_residual, r_size);}/* generate variable length code for other DCT coefficients (7.2.2)*/static void mp2PutAC(Ipp32u **pBitStream,                     Ipp32s *pOffset,                     Ipp32s run,                     Ipp32s signed_level,                     IppVCHuffmanSpec_32s *ptab){    Ipp32s level, code, len;    Ipp32s maxRun = ptab[0] >> 20;    Ipp32s addr;    Ipp32s * table;    Ipp32u val;    if(run > maxRun)    {        /* no VLC for this (run, level) combination: use escape coding (7.2.2.3)*/        /* ISO/IEC 13818-2 uses a 12 bit code, Table B-16*/        signed_level &= (1 << 12) - 1;        val = signed_level + (run<<12) + (1<<18);        ippiPutBits(*pBitStream, *pOffset, val, 24 )        return;    }    level = (signed_level < 0) ? -signed_level : signed_level;    addr = ptab[run + 1];    table = (Ipp32s*)((Ipp8s*)ptab + addr);    if(level <= table[0])    {        len  = *(table + signed_level) & 0x1f;        code = (*(table + signed_level) >> 16);        ippiPutBits(*pBitStream, *pOffset,  code, len )    }    else    {        /* no VLC for this (run, level) combination: use escape coding (7.2.2.3)*/        /* ISO/IEC 13818-2 uses a 12 bit code, Table B-16*/        signed_level &= (1 << 12) - 1;        val = signed_level + (run<<12) + (1<<18);        ippiPutBits(*pBitStream, *pOffset, val, 24 )    }}static IppStatus mp2PutIntraBlock(Ipp32u **pBitStream,                          Ipp32s  *pOffset,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -