aboutsummaryrefslogtreecommitdiff
path: root/src/creator.h
blob: 99735c5192f136fd90fc260e0eef511376477aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * render.h
 *
 *  Created on: 26.01.2018
 *      Author: rigtopa
 *
 */

#ifndef CREATOR_H_
#define CREATOR_H_

#include <string.h>
#include <libavcodec/avcodec.h>
#include <libavutil/frame.h>
#include <libavutil/imgutils.h>
#include "defs.h"

#define CLIP(X) ( (X) > 255 ? 255 : (X) < 0 ? 0 : X)

// RGB -> YUV
#define RGB2Y(R, G, B) CLIP(( (  66 * (R) + 129 * (G) +  25 * (B) + 128) >> 8) +  16)
#define RGB2U(R, G, B) CLIP(( ( -38 * (R) -  74 * (G) + 112 * (B) + 128) >> 8) + 128)
#define RGB2V(R, G, B) CLIP(( ( 112 * (R) -  94 * (G) -  18 * (B) + 128) >> 8) + 128)


AVFrame *picture;
AVPacket *pkt;

FILE *f;

u64 pts_old;


const AVCodec *codec;
AVCodecContext *avc;
int creator_i, creator_ret, creator_x, creator_y;

static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, FILE *outfile);

int generateVideo(const char *filename, int width, int height, int fps, int bitRate);

void addFrame(int *frame);

void endFile(void);

#endif