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

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

coded_picture_width = vsm2dec_output->coded_picture_width;

hor_size = vsm2dec_output->mpeg2_data->sequence_header.horizontal_size;

ver_size = vsm2dec_output->mpeg2_data->sequence_header.vertical_size;

chroma_format = vsm2dec_output->mpeg2_data->sequence_extension.chroma_format;

/// Saving Y matrix

buffer = vsm2dec_output->Y;

for (i=0; i<ver_size; i++)

{

fwrite(buffer, 1, hor_size, dump_file);

buffer += coded_picture_width;

}

/// Chroma format depending data's changing

if (chroma_format!=3) /// !=CHROMA444

{

coded_picture_width >>= 1;

hor_size >>= 1;

if (chroma_format==1) ver_size >>=1; /// ==CHROMA422

}

/// Saving U matrix

buffer = vsm2dec_output->U;

for (i=0; i<ver_size; i++)

{

fwrite(buffer, 1, hor_size, dump_file);

buffer += coded_picture_width;

}

/// Saving V matrix

buffer = vsm2dec_output->V;

for (i=0; i<ver_size; i++)

{

fwrite(buffer, 1, hor_size, dump_file);

buffer += coded_picture_width;

}

fclose(dump_file);

}

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

void dump_title_output(vsm2tenc_input_t *vsm2tenc_input)

{

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("Title_dump.yuv", "wb");

first_call = 0;

}

else

dump_file = fopen("Title_dump.yuv", "ab");

coded_picture_width = vsm2tenc_input->coded_picture_width;

hor_size = vsm2tenc_input->mpeg2_data->sequence_header.horizontal_size;

ver_size = vsm2tenc_input->mpeg2_data->sequence_header.vertical_size;

chroma_format = vsm2tenc_input->mpeg2_data->sequence_extension.chroma_format;

/// Saving Y matrix

buffer = vsm2tenc_input->Y;

for (i=0; i<ver_size; i++)

{

fwrite(buffer, 1, hor_size, dump_file);

buffer += coded_picture_width;

}

/// Chroma format depending data's changing

if (chroma_format!=3) /// !=CHROMA444

{

coded_picture_width >>= 1;

hor_size >>= 1;

if (chroma_format==1) ver_size >>=1; /// ==CHROMA422

}

/// Saving U matrix

buffer = vsm2tenc_input->U;

for (i=0; i<ver_size; i++)

{

fwrite(buffer, 1, hor_size, dump_file);

buffer += coded_picture_width;

}

/// Saving V matrix

buffer = vsm2tenc_input->V;

for (i=0; i<ver_size; i++)

{

fwrite(buffer, 1, hor_size, dump_file);

buffer += coded_picture_width;

}

fclose(dump_file);

}

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

int main(int argc, char *argv[])

{

void *decoder;

void *title;

void *encoder;

vsm2dec_options_t vsm2dec_options;

vsm2dec_output_t vsm2dec_output;

vsm2tenc_input_t vsm2tenc_input;

FILE *input_file, *output_file;

unsigned char *input_filename,  *title_filename, *output_filename;

unsigned char *decoder_coded_data, *encoder_coded_data;

unsigned int bytes_read, bytes_encoded;

unsigned int title_status, encoder_status;

signed int frame_id, frame_number;

unsigned int title_width, title_height;

time_t time0,time1;

printf("VSS MPEG2 title transcoder (vsm2title)\n");

printf("Copyright (C) 2007 Vanguard Software Solutions, Inc. All rights reserved.\n\n");

decoder = NULL;

title = NULL;

encoder = NULL;

input_file = output_file = NULL;

decoder_coded_data = encoder_coded_data = NULL;

if (argc < 5)

{

printf("USAGE:\n");

printf("vsm2title [input file] [title file] [title_width] [title_height] <output file>\n");

printf("WHERE:\n");

printf("    input file - input MPEG2 Video Stream file [mandatory];\n");

printf("    title file - input YUV file [mandatory];\n");

printf("    title_width - width of YUV file [mandatory];\n");

printf("    title_height - height of YUV file [mandatory];\n");

printf("    output file - output MPEG2 file [optional];\n");

return 0;

}

input_filename  = argv[1];

title_filename = argv[2];

title_width = atoi(argv[3]);

title_height = atoi(argv[4]);