| 318 | } |
| 319 | |
| 320 | static av_cold int oh_encode_init(AVCodecContext *avctx) |
| 321 | { |
| 322 | OHCodecEncContext *s = avctx->priv_data; |
| 323 | |
| 324 | // Initialize these fields first, so oh_decode_close can destroy them safely |
| 325 | ff_mutex_init(&s->input_mutex, NULL); |
| 326 | ff_cond_init(&s->input_cond, NULL); |
| 327 | ff_mutex_init(&s->output_mutex, NULL); |
| 328 | ff_cond_init(&s->output_cond, NULL); |
| 329 | |
| 330 | int ret = oh_encode_create(s, avctx); |
| 331 | if (ret < 0) |
| 332 | return ret; |
| 333 | ret = oh_encode_set_format(s, avctx); |
| 334 | if (ret < 0) |
| 335 | return ret; |
| 336 | |
| 337 | size_t fifo_size = 16; |
| 338 | s->input_queue = av_fifo_alloc2(fifo_size, sizeof(OHBufferQueueItem), |
| 339 | AV_FIFO_FLAG_AUTO_GROW); |
| 340 | s->output_queue = av_fifo_alloc2(fifo_size, sizeof(OHBufferQueueItem), |
| 341 | AV_FIFO_FLAG_AUTO_GROW); |
| 342 | s->frame = av_frame_alloc(); |
| 343 | if (!s->input_queue || !s->output_queue || !s->frame) |
| 344 | return AVERROR(ENOMEM); |
| 345 | |
| 346 | ret = oh_encode_start(s, avctx); |
| 347 | if (ret < 0) |
| 348 | return ret; |
| 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | static av_cold int oh_encode_close(AVCodecContext *avctx) |
| 354 | { |
nothing calls this directly
no test coverage detected