Улучшение отношения сигнал/шум при микшировании видео изображения, сжатого по стандарту MPEG2, страница 24

* Counts encoded data size.

*

* @param encoder [In] - valid encoder session context

* @param time_stamp [In/Out] - DirectShow time_stamp for proper video/audio synchronization

* @return encoded data size

**/

t_ui32 vsm2tenc_get_encoded_data_size(void *encoder, __int64 *time_stamp);

/**

* Putting SEQUENCE_END_START_CODE for proper finalization of video stream.

*

* @param encoder [In] - valid encoder session context

* @param coded_data [Out] - buffer for encoded data

* @param coded_data_size [In] - size of buffer for encoded data

* @return bytes encoded

**/

t_ui32 vsm2tenc_finalize_sequence(void *encoder, t_ui8 *coded_data, t_ui32 coded_data_size);

/**

* Release encoder, destruction encoder session.

*

* @param encoder [In] - valid encoder session context

**/

void vsm2tenc_release(void *encoder);

#ifdef __cplusplus

}

#endif

#endif   //_VSM2TENC_VSM2TENC_API_H

Тестовое консольное приложение

/**

* @file api_test.c

* Console MPEG2 Title transcoder

*

* - Project: MPEG2 Title transcoder

* - Copyright (c) 2002-2006 Vanguard Software Solutions, Inc.

* - All rights reserved

**/

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

#include <time.h>

#ifdef WIN32

#include <windows.h>

#endif

#include "vsm2dec_api.h"

#include "title_api.h"

#include "vsm2tenc_api.h"

#define DECODER_BUFFER_SIZE                   4096

#define ENCODER_BUFFER_SIZE                2073600  /// 1920x1080 - HD

//#define DUMP_DECODER_OUTPUT

//#define DUMP_TITLE_OUTPUT

#ifdef WIN32

__int64 lFrequency, lStart, lEnd, lTicks;

double dTicks, dFreq, dSeconds, dFps;

static void perf_init()

{

QueryPerformanceFrequency((LARGE_INTEGER*)&lFrequency);

lTicks = 0;

}

static void perf_start()

{

QueryPerformanceCounter((LARGE_INTEGER*)&lStart);

}

static void perf_end()

{

QueryPerformanceCounter((LARGE_INTEGER*)&lEnd);

}

//////////////////////////////////////////////////////////////////////////

static void perf_report(int frame_num, time_t total_time)

{

dTicks = (double)lTicks;

dFreq  = (double)lFrequency;

dSeconds  = dTicks / dFreq;

dFps = frame_num;

dFps /= dSeconds;

printf("\n");

printf("Processed frames:     %u\n", frame_num);

printf("Processing time:      %.2f sec\n", dSeconds);

printf("Processing speed:     %.2f fps\n", dFps);

printf("Total time:             %u sec\n", total_time);

}

#else

static void perf_init(){}

static void perf_start(){}

static void perf_end(){}

static void perf_report(int frame_num){}

#endif

//////////////////////////////////////////////////////////////////////////

void report_decoder_errors(unsigned int error_log)

{

if (error_log & VSM2DEC_ERROR_MACROBLOCK_ADDR_INC)      printf("                    - VSM2DEC_ERROR_MACROBLOCK_ADDRESS_INCREMENT\n");

if (error_log & VSM2DEC_ERROR_MACROBLOCK_TYPE)          printf("                    - VSM2DEC_ERROR_MACROBLOCK_TYPE\n");

if (error_log & VSM2DEC_ERROR_CODED_BLOCK_PATTERN)      printf("                    - VSM2DEC_ERROR_CODED_BLOCK_PATTERN\n");

if (error_log & VSM2DEC_ERROR_VLD_AC_COEF)              printf("                    - VSM2DEC_ERROR_VLD_AC_COEF\n");

if (error_log & VSM2DEC_ERROR_VLD_OVERFLOW)             printf("                    - VSM2DEC_ERROR_VLD_OVERFLOW\n");

if (error_log & VSM2DEC_ERROR_MARKER_BIT)               printf("                    - VSM2DEC_ERROR_MARKER_BIT\n");

if (error_log & VSM2DEC_ERROR_MOTION_VECTOR_INCORRECT ) printf("                    - VSM2DEC_ERROR_MOTION_VECTOR_INCORRECT \n");

}

//////////////////////////////////////////////////////////////////////////

void dump_vsm2dec_output(vsm2dec_output_t *vsm2dec_output)

{

static int first_call = 1;

FILE *dump_file;

unsigned int i;

unsigned char * buffer;

int coded_picture_width, hor_size;

unsigned char chroma_format;

unsigned int ver_size;

if (first_call)

{

dump_file = fopen("Decoder_dump.yuv", "wb");

first_call = 0;

}

else