www.pudn.com > rm52c.rar > output.c
/* *********************************************************************** * COPYRIGHT AND WARRANTY INFORMATION * * Copyright 2003, Advanced Audio Video Coding Standard, Part II * * DISCLAIMER OF WARRANTY * * These software programs are available to the users without any * license fee or royalty on an "as is" basis. The AVS disclaims * any and all warranties, whether express, implied, or statutory, * including any implied warranties of merchantability or of fitness * for a particular purpose. In no event shall the contributors or * the AVS be liable for any incidental, punitive, or consequential * damages of any kind whatsoever arising from the use of this program. * * This disclaimer of warranty extends to the user of this program * and user's customers, employees, agents, transferees, successors, * and assigns. * * The AVS does not represent or warrant that the program furnished * hereunder are free of infringement of any third-party patents. * Commercial implementations of AVS, including shareware, may be * subject to royalty fees to patent holders. Information regarding * the AVS patent policy is available from the AVS Web site at * http://www.avs.org.cn * * THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY. ************************************************************************ */ /* ************************************************************************************* * File name: output.c * Function: Output an image and Trance support * ************************************************************************************* */ #include "contributors.h" #include "global.h" #include/* ************************************************************************* * Function:Write decoded frame to output file * Input: * Output: * Return: * Attention: ************************************************************************* */ void write_frame( struct img_par *img, //!< image parameter FILE *p_out) //!< filestream to output file { int i,j; for(i=0;i height;i++) for(j=0;j width;j++) { fputc(imgY[i][j],p_out); } for(i=0;i height_cr;i++) for(j=0;j width_cr;j++) { fputc(imgUV[0][i][j],p_out); } for(i=0;i height_cr;i++) for(j=0;j width_cr;j++) { fputc(imgUV[1][i][j],p_out); } fflush(p_out); } /* ************************************************************************* * Function:Write previous decoded P frame to output file * Input: * Output: * Return: * Attention: ************************************************************************* */ void write_prev_Pframe(struct img_par *img, FILE *p_out) { int i,j; for(i=0;i height;i++) for(j=0;j width;j++) fputc(imgY_prev[i][j],p_out); for(i=0;i height_cr;i++) for(j=0;j width_cr;j++) fputc(imgUV_prev[0][i][j],p_out); for(i=0;i height_cr;i++) for(j=0;j width_cr;j++) fputc(imgUV_prev[1][i][j],p_out); fflush( p_out ); } #if TRACE static int bitcounter = 0; /* ************************************************************************* * Function:Tracing bitpatterns for symbols A code word has the following format: 0 Xn...0 X2 0 X1 0 X0 1 * Input: * Output: * Return: * Attention: ************************************************************************* */ void tracebits( const char *trace_str, //!< tracing information, char array describing the symbol int len, //!< length of syntax element in bits int info, //!< infoword of syntax element int value1) { int i, chars; if(len>=34) { snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work"); error (errortext, 600); } putc('@', p_trace); chars = fprintf(p_trace, "%i", bitcounter); while(chars++ < 6) putc(' ',p_trace); chars += fprintf(p_trace, "%s", trace_str); while(chars++ < 55) putc(' ',p_trace); // Align bitpattern if(len<15) { for(i=0 ; i<15-len ; i++) fputc(' ', p_trace); } // Print bitpattern for(i=0 ; i > ((len/2-i)-1))) fputc('1', p_trace); else fputc('0', p_trace); } fprintf(p_trace, " (%3d)\n", value1); bitcounter += len; fflush (p_trace); } /* ************************************************************************* * Function:Tracing bitpatterns * Input: * Output: * Return: * Attention: ************************************************************************* */ void tracebits2( const char *trace_str, //!< tracing information, char array describing the symbol int len, //!< length of syntax element in bits int info) { int i, chars; if(len>=45) { snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work"); error (errortext, 600); } putc('@', p_trace); chars = fprintf(p_trace, "%i", bitcounter); while(chars++ < 6) putc(' ',p_trace); chars += fprintf(p_trace, "%s", trace_str); while(chars++ < 55) putc(' ',p_trace); // Align bitpattern if(len<15) for(i=0 ; i<15-len ; i++) fputc(' ', p_trace); bitcounter += len; while (len >= 32) { for(i=0 ; i<8 ; i++) { fputc('0', p_trace); } len -= 8; } // Print bitpattern for(i=0 ; i > (len-i-1))) fputc('1', p_trace); else fputc('0', p_trace); } fprintf(p_trace, " (%3d)\n", info); fflush (p_trace); } /* ************************************************************************* * Function:Tracing bitpatterns for symbols * Input: * Output: * Return: * Attention: ************************************************************************* */ void tracebits3( const char *trace_str, //!< tracing information, char array describing the symbol int len, //!< length of syntax element in bits int info, //!< infoword of syntax element int value1) { int i, chars; if(len>=34) { snprintf(errortext, ET_SIZE, "Length argument to put too long for trace to work"); error (errortext, 600); } putc('@', p_trace); chars = fprintf(p_trace, "%i", bitcounter); while(chars++ < 6) putc(' ',p_trace); chars += fprintf(p_trace, "%s", trace_str); while(chars++ < 55) putc(' ',p_trace); // Align bitpattern if(len<15) { for(i=0 ; i<15-len ; i++) fputc(' ', p_trace); } // Print bitpattern for(i=0 ; i > (len-i-1))) fputc('1', p_trace); else fputc('0', p_trace); } fprintf(p_trace, " (%3d)\n", value1); bitcounter += len; fflush (p_trace); } #endif