tda4 videnc-test-app: 单帧YUV拼接为多帧

因 videnc-test-app 编码需要连续帧,于是写了一个简单的单帧YUV图片拼接成多帧的c程序。

#include
#include
#include
#include

int main()
{
    long int len = 0;
    char *ch = NULL;

    FILE *fp1 = fopen("./0-0-down.yuv", "r");
    FILE *fp2 = fopen("./1-0-down.yuv", "r");
    FILE *fp3 = fopen("mix.yuv", "w+");

    if (fp1 == NULL)
        printf("open file failt...\n");

    fseek(fp1, 0, SEEK_END);
    len = ftell(fp1);
    printf("fp1 len = %ld\n", len);
    ch = (char *)malloc(sizeof(char *) * len);
    memset(ch, 0, len);

    rewind(fp1);
    fread(ch, 1, len, fp1);
    fwrite(ch, 1, len, fp3);
    fwrite(ch, 1, len, fp3);

    ch = NULL;
    len = 0;
    fseek(fp2, 0, SEEK_END);
    len = ftell(fp2);
    printf("fp2 len = %ld\n", len);
    ch = (char *)malloc(sizeof(char *) * len);
    memset(ch, 0, len);

    rewind(fp2);
    fread(ch, 1, len, fp2);
    fwrite(ch, 1, len, fp3);
    fwrite(ch, 1, len, fp3);


    fclose(fp1);
    fclose(fp2);
    fclose(fp3);

    return 0;
}

你可能感兴趣的:(Embedded,c)