MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / main

Function main

tests/api/api-h264-slice-test.c:110–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110int main(int argc, char **argv)
111{
112 const AVCodec *codec = NULL;
113 AVCodecContext *c = NULL;
114 AVFrame *frame = NULL;
115 unsigned int threads;
116 AVPacket *pkt;
117 FILE *file = NULL;
118 char * nal = NULL;
119 int nals = 0, ret = 0;
120 char *p;
121
122 if (argc < 3) {
123 fprintf(stderr, "Usage: %s <threads> <input file>\n", argv[0]);
124 return -1;
125 }
126
127 if (!(threads = strtoul(argv[1], NULL, 0)))
128 threads = 1;
129 else if (threads > MAX_SLICES)
130 threads = MAX_SLICES;
131
132#ifdef _WIN32
133 setmode(fileno(stdout), O_BINARY);
134#endif
135
136 if (!(pkt = av_packet_alloc())) {
137 return -1;
138 }
139
140 nal = av_malloc(MAX_SLICES * UINT16_MAX + AV_INPUT_BUFFER_PADDING_SIZE);
141 if (!nal)
142 goto err;
143 p = nal;
144
145 if (!(codec = avcodec_find_decoder(AV_CODEC_ID_H264))) {
146 fprintf(stderr, "Codec not found\n");
147 ret = -1;
148 goto err;
149 }
150
151 if (!(c = avcodec_alloc_context3(codec))) {
152 fprintf(stderr, "Could not allocate video codec context\n");
153 ret = -1;
154 goto err;
155 }
156
157 c->width = 352;
158 c->height = 288;
159
160 c->flags2 |= AV_CODEC_FLAG2_CHUNKS;
161 c->thread_type = FF_THREAD_SLICE;
162 c->thread_count = threads;
163
164 if ((ret = avcodec_open2(c, codec, NULL)) < 0) {
165 fprintf(stderr, "Could not open codec\n");
166 goto err;
167 }

Callers

nothing calls this directly

Calls 11

av_packet_allocFunction · 0.85
avcodec_find_decoderFunction · 0.85
avcodec_alloc_context3Function · 0.85
avcodec_open2Function · 0.85
av_frame_allocFunction · 0.85
av_frame_freeFunction · 0.85
avcodec_free_contextFunction · 0.85
av_packet_freeFunction · 0.85
decodeFunction · 0.70
av_mallocFunction · 0.50
av_freeFunction · 0.50

Tested by

no test coverage detected