www.pudn.com > henclib263.rar > pictureI.cxx
/*
* picureI.cxx
*
* implementation for frame(I frame) level funcitons .
*
* Copyright (c) 2002-2004 Li Chun-lin(li_chunlin@263.net)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../include/picture.h"
#include "../include/macroblock.h"
#include "../include/vlc.h"
#include "../include/bitstream.h"
#include "../include/image.h"
#ifdef __cplusplus
extern "C" {
#endif
// Name : EncIfrm
// Input : H263VencStatus
// Output : Encoded Intra Picture
// Description : Encode one I frame
/*! Last modified on 2002.12.5 by zj */
int EncIfrm (H263VencStatus *curr_encode_status)
{
int i, j;
short mb_coeff[384]; //mb data encoded 384 = 8*8 * (4+1+1).
int COD = 0;
int CBP;
int dquant = 0;
int mb_mode = MODE_INTRA;
int frame_total_bits = 0;
int gob_nbr = 0;
int gob_quant = curr_encode_status->total_Q;
if (curr_encode_status->version2)
{
frame_total_bits += EncPicHdrPlus(curr_encode_status);
}
else
{
frame_total_bits += EncPicHdr(curr_encode_status);
}
for (i = 0; i < curr_encode_status->lines; i += 16)
{
if(curr_encode_status->gobsync && i && (i/16)%(curr_encode_status->gobsync) == 0)
{
gob_nbr++;
frame_total_bits += EncGOBHdr(gob_nbr, curr_encode_status->gfid, gob_quant, curr_encode_status->TR, 0);
}
for (j = 0; j < curr_encode_status->pels; j += 16)
{
CBP = MB_Encode_I (curr_encode_status, j, i, mb_coeff);
/* take down the code information of current mb */
curr_encode_status->coded_tab[i/16+1][j/16+1] = 1;
curr_encode_status->quant_tab[i/16+1][j/16+1] = curr_encode_status->total_Q;
frame_total_bits += EncMBHdr(curr_encode_status->PTYPE, mb_mode, COD, CBP, dquant);
frame_total_bits += EncCoeff(1, CBP, mb_coeff, 64);
}
}
frame_total_bits += alignbits();
clear_buff();
if (curr_encode_status->filter)
{
EdgeFilter(curr_encode_status);
}
if (curr_encode_status->mv_outside_frame)
{
MakeEdgeImage(curr_encode_status);
}
return frame_total_bits;
}
#ifdef __cplusplus
}
#endif