#include <stdio.h>
#include <stdlib.h>
#define MAXPACKETSIZE 50000 //Ģegethos paketon
//Dimiourgia PACKET LOSS pou kathorizetai apo to arxeio error
int looseit(FILE *err){
int c;
do {
c = getc (err);
if (c == EOF) {
fseek(err, 0, SEEK_SET);
}
else if (c == '0') return 1;
else return 0;
} while (1);
}
int main(){
FILE *in, *out, *err0=NULL;
unsigned char buf[MAXPACKETSIZE];
unsigned char nal_type;
int i;
int packet_number=0;
char command_line[1000];
printf("Starting video encoding!\n");
printf("\n\n Please Wait!!! \n\n");
//Kodikopoihsh tou video foreman_cif.yuv kai paragogi tou BINARY FILE hevc.bin
sprintf(command_line,"%s","TAppEncoder.exe -c cfg\\encoder_randomaccess_main.cfg -q 26 -fr 30 -wdt 352 -hgt 288 -f 300 -i foreman_cif.yuv -b hevc.bin");
system(command_line);
printf("End of video encoding!\n");
printf("Starting video transmition \n\n");
printf("A number of packets are going to be lost!!! \n\n");
printf("\n\n Please Wait!!! \n\n");
if (NULL == (in = fopen("rec.yuv","rb"))) {
perror("Cannot read input binary file that generated by the video file!");
exit(1);
}
if (NULL == (out = fopen("hevc_loss.yuv","wb"))) {
perror("Cannot open destination binary file with errors");
exit(2);
}
if (NULL == (err0 = fopen ("error", "rb"))) {
perror ("Cannot open error pattern file");
exit (3);
}
//Dimiourgia sfalmaton sto binary file
buf[0]=fgetc(in);
buf[1]=fgetc(in);
buf[2]=fgetc(in);
buf[3]=fgetc(in);
buf[4] = fgetc(in);
nal_type = buf[4] & 0x0F;
for(i=5; ; i++)
{
buf[i] = fgetc(in);
if(feof(in)==0)
{
if(buf[i-3]==0 && buf[i-2]==0 && buf[i-1]==0 && buf[i]==1)
{
fwrite(buf, sizeof(unsigned char), i-3, out);
packet_number++;
fflush(out);
buf[0]=buf[i-3];
buf[1]=buf[i-2];
buf[2]=buf[i-1];
buf[3]=buf[i];
break;
}
}
}
while(feof(in)==0)
{
for(i=4; ;i++)
{
buf[i] = fgetc(in);
nal_type = buf[4] & 0x1F;
if(feof(in)==0)
{
if(buf[i-3]==0 && buf[i-2]==0 && buf[i-1]==0 && buf[i]==1 )
{
if(nal_type==1 || nal_type==20)
{
if(err0 != NULL && looseit(err0)){
}
else
{
fwrite(buf, sizeof(unsigned char), i-3, out);
fflush(out);
}
}
else
{
fwrite(buf, sizeof(unsigned char), i-3, out);
fflush(out);
}
packet_number++;
buf[0]=buf[i-3];
buf[1]=buf[i-2];
buf[2]=buf[i-1];
buf[3]=buf[i];
break;
}
}
else
{
fwrite(buf, sizeof(unsigned char), i, out);
fflush(out);
break;
}
}
}
fclose(in);
fclose(out);
if ( err0)
fclose(err0);
printf("End of transmition!!!\n\n");
printf("Starting video decoding\n\n");
printf("\n\n Please Wait!!! \n\n");
sprintf(command_line,"%s","TAppDecoder.exe -b hevc_loss.bin -o foreman_cif_loss.yuv");
system(command_line);
printf("End of video decoding!!!\n\n");
return 0;
}
How to encode and decode instead of foreman the yuv : soccer_704x576_60_orig_02_yuv.zip186272 kb, 60 fig. per second, using the previous code (hevc) ? and how to evaluate the psnr for the decoded yuv for 2 different profiles of HEVC random Access (RA-HE) & (RA-LC) and various BER (10^-4, 10^-5,10^-6)?
0.42dB RAHE(random access high efficiency) 0.44dB RA LC (random access low complexity)
+ Reply to Thread
Results 1 to 3 of 3
-
-
what exactly are you asking? and what does that small snippet of code have to do with it?
p.s. judging by the comments in the code, if it's your code, i'm guessing greek is your primary language, i speak greek, if that is your preferred language pm me in greek and i will try and answer your question.
Similar Threads
-
theX.265 (a free HEVC) codec. Have you ever tried that HEVC encoder? (HELP)
By Stears555 in forum Video ConversionReplies: 41Last Post: 16th Sep 2013, 11:15 -
SOS! I have output file from convert by mencoder but i don't know conmand
By zerround in forum Video ConversionReplies: 0Last Post: 24th Feb 2012, 01:38 -
SOS Win7 Update hangfire- #8 never completes
By ahhaa in forum ComputerReplies: 3Last Post: 17th Feb 2012, 00:48 -
SOS- Registry Help Needed: Stop Repeating Windows Installer (XP)
By ahhaa in forum ComputerReplies: 6Last Post: 20th Nov 2011, 06:41 -
SOS: how to capture flv,
By dainova in forum Video Streaming DownloadingReplies: 6Last Post: 19th Oct 2011, 11:26