📄 shapeenhcommon.cpp
字号:
/****************************************************************************/
/* MPEG4 Visual Texture Coding (VTC) Mode Software */
/* */
/* This software was jointly developed by the following participants: */
/* */
/* Single-quant, multi-quant and flow control */
/* are provided by Sarnoff Corporation */
/* Iraj Sodagar (iraj@sarnoff.com) */
/* Hung-Ju Lee (hjlee@sarnoff.com) */
/* Paul Hatrack (hatrack@sarnoff.com) */
/* Shipeng Li (shipeng@sarnoff.com) */
/* Bing-Bing Chai (bchai@sarnoff.com) */
/* B.S. Srinivas (bsrinivas@sarnoff.com) */
/* */
/* Bi-level is provided by Texas Instruments */
/* Jie Liang (liang@ti.com) */
/* */
/* Shape Coding is provided by OKI Electric Industry Co., Ltd. */
/* Zhixiong Wu (sgo@hlabs.oki.co.jp) */
/* Yoshihiro Ueda (yueda@hlabs.oki.co.jp) */
/* Toshifumi Kanamaru (kanamaru@hlabs.oki.co.jp) */
/* */
/* OKI, Sharp, Sarnoff, TI and Microsoft contributed to bitstream */
/* exchange and bug fixing. */
/* */
/* Scalable Shape Coding was provided by: */
/* Shipeng Li (Sarnoff Corporation), */
/* Dae-Sung Cho (Samsung AIT), */
/* Se Hoon Son (Samsung AIT) */
/* In the course of development of the MPEG-4 standard, this software */
/* module is an implementation of a part of one or more MPEG-4 tools as */
/* specified by the MPEG-4 standard. */
/* */
/* The copyright of this software belongs to ISO/IEC. ISO/IEC gives use */
/* of the MPEG-4 standard free license to use this software module or */
/* modifications thereof for hardware or software products claiming */
/* conformance to the MPEG-4 standard. */
/* */
/* Those intending to use this software module in hardware or software */
/* products are advised that use may infringe existing patents. The */
/* original developers of this software module and their companies, the */
/* subsequent editors and their companies, and ISO/IEC have no liability */
/* and ISO/IEC have no liability for use of this software module or */
/* modification thereof in an implementation. */
/* */
/* Permission is granted to MPEG members to use, copy, modify, */
/* and distribute the software modules ( or portions thereof ) */
/* for standardization activity within ISO/IEC JTC1/SC29/WG11. */
/* */
/* Copyright 1995, 1996, 1997, 1998 ISO/IEC */
/****************************************************************************/
/************************************************************************/
/* */
/* This software module was originally developed by */
/* */
/* Dae-Sung Cho (Samsung AIT), */
/* Se Hoon Son (Samsung AIT) */
/* */
/* and edited by */
/* Dae-Sung Cho (Samsung AIT) */
/* */
/* in the course of development of the MPEG-4 Video(ISO/IEC 14496-2). */
/* This software module is an implementation of a part of one or */
/* more MPEG-4 Video tools as specified by the */
/* MPEG-4 Video(ISO/IEC 14496-2). */
/* */
/* ISO/IEC gives users of the MPEG-4 Video(ISO/IEC 14496-2) */
/* free license to this software module or modifications thereof */
/* for use in hardware or software products claiming conformance */
/* to the MPEG-4 Video(ISO/IEC 14496-2). */
/* */
/* Those intending to use this software */
/* module in hardware or software products are advised that its */
/* use may infringe existing patents. The original developer of */
/* this software module and his/her company, the subsequent */
/* editors and their companies, and ISO/IEC have no liability */
/* for use of this software module or modifications thereof in */
/* an implementation. Copyright is not released for non */
/* MPEG-4 Video(ISO/IEC 14496-2) conforming products. */
/* */
/* Samsung AIT (SAIT) retain full right to use the code for */
/* their own purposes, assign or donate the code to a third party */
/* and to inhibit third parties from using the code for non */
/* MPEG-4 Video(ISO/IEC 14496-2) conforming products. */
/* */
/* This copyright notice must be included in all copies or */
/* derivative works. */
/* Copyright (c) 1997, 1998 */
/* */
/************************************************************************/
/***********************************************************HeaderBegin*******
*
* File: ShapeEnhCommon.c
*
* Author: Dae-Sung Cho (Samsung AIT)
* Created: 09-Feb-98
* Modified by: Shipeng Li (Sarnoff Corporation), Dec 2, 1998.
* Description: Contains functions used to implement scan interleaving
* coding of spatial scalable binary alpha blocks.
*
*
*
***********************************************************HeaderEnd*********/
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include "dataStruct.hpp"
#include "ShapeEnhDef.hpp"
//#include "ShapeEnhCommon.h"
Int CVTCCommon::
GetContextEnhBAB_XOR(UChar *curr_bab_data,
Int x2,
Int y2,
Int width2,
Int pixel_type) /* pixel type : 0-P1, 1-P2/P3 */
{
Int t=0;
UChar *p;
if(pixel_type==0) /* P1 pixel */
{
p=curr_bab_data + (y2-2) * width2 + x2-1;
t <<= 1; t |= *p; p++; /* c6 */
t <<= 1; t |= *p; p++; /* c5 */
t <<= 1; t |= *p; p+=((width2<<1)-2); /* c4 */
t <<= 1; t |= *p; p+=2; /* c3 */
t <<= 1; t |= *p; p+=((width2<<1)-2); /* c2 */
t <<= 1; t |= *p; p+=2; /* c1 */
t <<= 1; t |= *p; /* c0 */
}
else /* P2/P3 band */
{
p=curr_bab_data + (y2-1) * width2 + x2-1;
t <<= 1; t |= *p; p++; /* c6 */
t <<= 1; t |= *p; p++; /* c5 */
t <<= 1; t |= *p; p+=(width2-2); /* c4 */
t <<= 1; t |= *p; p+=width2; /* c3 */
t <<= 1; t |= *p; p++; /* c2 */
t <<= 1; t |= *p; p++; /* c1 */
t <<= 1; t |= *p; /* c0 */
}
return t;
}
Int CVTCCommon::
GetContextEnhBAB_FULL(UChar *lower_bab_data,
UChar *curr_bab_data,
Int x2,
Int y2,
Int width,
Int width2)
{
Int t=0;
Int x = x2 >> 1,
y = y2 >> 1;
UChar *p, *q;
p = lower_bab_data + y*width + x;
q = curr_bab_data + (y2-1) * width2 + (x2-1);
t <<= 1; t |= *p; p++; /* c7 */
t <<= 1; t |= *p; p+= width-1; /* c6 */
t <<= 1; t |= *p; p++; /* c5 */
t <<= 1; t |= *p; /* c4 */
t <<= 1; t |= *q; q++; /* c3 */
t <<= 1; t |= *q; q++; /* c2 */
t <<= 1; t |= *q; q+=(width2-2); /* c1 */
t <<= 1; t |= *q; /* c0 */
return t;
}
// SAIT_PDAM BEGIN - ADDED by Dae-Sung Cho (Samsung AIT)
Int CVTCCommon::DecideScanOrder(UChar *bordered_lower_bab, Int mbsize)
{
Int scan_order;
Int border = BORDER;
Int bsize = mbsize >> 1;
Int bsize_ext = bsize+(border<<1);
Int i,j;
Int num_right=0, num_bottom=0;
UChar *lower_bab_data;
lower_bab_data = bordered_lower_bab + border * bsize_ext + border;
for(j=0;j<bsize;j++){
for(i=0;i<bsize;i++){
if( *(lower_bab_data+j*bsize_ext + i) != *(lower_bab_data+j*bsize_ext + i+1))
num_right++;
if( *(lower_bab_data+j*bsize_ext + i) != *(lower_bab_data+(j+1)*bsize_ext + i))
num_bottom++;
}
}
if(num_bottom <= num_right) scan_order = 0;
else scan_order = 1;
return(scan_order);
}
// SAIT_PDAM END - ADDED by Dae-Sung Cho (Samsung AIT)
Void CVTCCommon::
AddBorderToBABs(UChar *LowShape,
UChar *HalfShape,
UChar *CurShape,
UChar *lower_bab,
UChar *half_bab,
UChar *curr_bab,
UChar *bordered_lower_bab,
UChar *bordered_half_bab,
UChar *bordered_curr_bab,
Int object_width, /* object_width in the current layer */
Int object_height, /* object_height in the current layer */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -