VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. #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)
    Quote Quote  
  2. Banned
    Join Date
    Nov 2005
    Location
    United States
    Search Comp PM
    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!